Product Search additional filter by code

Forums › Forums › Search & Filter Pro › Product Search additional filter by code

Viewing 3 posts – 1 through 3 (of 3 total)
  • Anonymous
    #129699

    Hi,

    I’m adding an additional parameter in the url, to append some meta_query to the filtered page. The problem is that my code is not affecting in the result and I am expecting that the search plugin is not allowing me to append to meta query!

    I am adding the following:

    function some_product_query( $q ) {
    if ( isset($_GET[‘check_vendor’]) ) {
    $meta_query = $q->get( ‘meta_query’ );

    $meta_query[‘relation’] = ‘AND’;
    $meta_query[] = array(
    array(
    ‘key’ => ‘product_vendor’,
    ‘value’ => ‘some_vendor’,
    ‘compare’ => ‘LIKE’
    )
    );

    $q->set( ‘meta_query’, $meta_query );
    }
    }

    the previous code is hooked to the action: woocommerce_product_query

    but it is not affecting the resulted screen. Could you please help whether this is caused because of your plugin? if yes, is it possible to solve it somehow?

    Trevor
    #129800

    The only code that I have seen like that is when using the Custom Display Results method, pre_get_posts method, as seen here:

    https://www.designsandcode.com/documentation/search-filter-pro/search-results/custom/#pre_get_posts

    Otherwise, you stand the risk that our filter will override your arguments. OR, you might be able to use this:

    https://www.designsandcode.com/documentation/search-filter-pro/action-filter-reference/#Edit_Query_Arguments

    Anonymous
    #130222

    The hook ‘sf_edit_query_args’ allowed me to update meta_query successfully.

    Thanks Trevor!

Viewing 3 posts – 1 through 3 (of 3 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.