Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro filter by “price higher than”

Viewing 4 posts - 1 through 4 (of 4 total)
  • Rafa Noguera
    #264344

    Hi,

    I need to filter the query, I need to get a filter that returns posts with meta “price” higher than value that user has filtered. I have tried this code, but is not working. Can you help me please?

    function filter_function_name( $query_args, $sfid ) {

    if($sfid==858){

    if(isset($_GET[‘_sfm_m2_from’]) && !isset($_GET[‘_sfm_price_from’])){

    $query_args[‘meta_query’] = array(
    array(
    ‘key’ => ‘m2_from’,
    ‘value’ => $_GET[‘_sfm_m2_from’],
    ‘compare’ => ‘>=’,
    ‘type’ => ‘NUMERIC’,
    ),
    );

    }

    if(isset($_GET[‘_sfm_price_from’]) && !isset($_GET[‘_sfm_m2_from’])){

    $query_args[‘meta_query’] = array(
    array(
    ‘key’ => ‘price_from’,
    ‘value’ => $_GET[‘_sfm_price_from’],
    ‘compare’ => ‘>=’,
    ‘type’ => ‘NUMERIC’,
    ),
    );

    }

    if(isset($_GET[‘_sfm_m2_from’]) && isset($_GET[‘_sfm_price_from’])){

    $query_args[‘meta_query’] = array(
    ‘relation’ => ‘AND’,
    array(
    ‘key’ => ‘m2_from’,
    ‘value’ => $_GET[‘_sfm_m2_from’],
    ‘compare’ => ‘>=’,
    ‘type’ => ‘NUMERIC’,
    ),
    array(
    ‘key’ => ‘price_from’,
    ‘value’ => $_GET[‘_sfm_price_from’],
    ‘compare’ => ‘>=’,
    ‘type’ => ‘NUMERIC’,
    ),
    );

    }

    }

    return $query_args;
    }
    add_filter( ‘sf_edit_query_args’, ‘filter_function_name’, 20, 2 );

    Regards

    Trevor Moderator
    #264380

    This is something we plan to address in V3 (due in a few months), but for now what you must do instead is to se the field as a range (From To) and set the TO value manually to a high number (well above any likely value). Then make sure there is no ‘Values Seperator’ set in the form field settings, and use CSS to hide the TO field in the front end.

    Rafa Noguera
    #264412

    ok Trevor, thank your for your help!

    Trevor Moderator
    #264424

    Let me know how you get on and if I can close this thread?

Viewing 4 posts - 1 through 4 (of 4 total)

The forum ‘Search & Filter Pro’ is closed to new topics and replies.