• Resolved JordanC26

    (@jordanc26)


    Hi,

    I am using woof_products_query to modify the products displayed on my ‘author’ page, so it shows only products by that author.

    Working

    function woof_modify_query( $query ) {
      
      // Check we're on a /shop page before filtering the product query.
      if( dokan_is_store_page() ) {
        
        $store_user = dokan()->vendor->get( get_query_var( 'author' ) );
        $query['author'] = $store_user->id;
    
        return $query;
    
      }
    
    }
    add_action( 'woof_products_query', __NAMESPACE__.'\\woof_modify_query' );

    It changes what products are displayed, but it does not affect the product filters. In this image, you can see there are “Showing 23 items”, and yet the Categories are still showing how many products are available across the whole site. Do you understand what I mean? I’ve included screenshots.

    Image #1
    https://ibb.co/D9kmcbz

    Image #2
    https://ibb.co/7v0WN63

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter JordanC26

    (@jordanc26)

    Post deleted.

    • This reply was modified 4 years, 7 months ago by JordanC26.
    • This reply was modified 4 years, 7 months ago by JordanC26.
    Thread Starter JordanC26

    (@jordanc26)

    Alternative:

    I’ve seen you can modify which child terms do not appear with this hook: woof_terms_where_hidden_childs

    Is there a hook to hide PARENT terms too?

    Thread Starter JordanC26

    (@jordanc26)

    I know you can exclude categories via the Settings. I want to exclude by a hook.

    Plugin Support mediawebster

    (@mediawebster)

    Hello

    Try to use $query['woof_author'] = $store_user->id;

    I want to exclude by a hook. – use this hook please – https://products-filter.com/hook/woof_sort_terms_before_out/

    Thread Starter JordanC26

    (@jordanc26)

    What exactly do we need to pass to this hook? The term ID, slug, both, full array?

    /**
     * Hide child taxonomy terms from defined parent ID.
     */
    function hide_taxonomy_terms() {
    
      $test_array = [
        'term_id' => '47',
      ];
    
      return $test_array;
    
    }
    add_filter('woof_sort_terms_before_out', __NAMESPACE__.'\\hide_taxonomy_terms' );
    Plugin Support mediawebster

    (@mediawebster)

    Hello

    This hook passes the array of terms(all). Find the desired term and remove it from the array

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Update product filters when using custom query’ is closed to new replies.