Support » Plugin: WooCommerce » Exclude Categories from Related Products

  • We use WooCommerce product categories for types and brands however are wanting to remove the types categories from displaying in related products and just showcase those that are the same brand.

    We found this solution:

    
    function exclude_brands_from_related( $categories ){
    // array of category id's that should be excluded
    $exclude_cats = array( '100', '101', '102');
    
    foreach( $categories as $index => $cat ){
        if( in_array( $cat->term_id, $exclude_cats ) ){
            unset($categories[$index]);
        }
    }
    
    return $categories;
    }
    
    add_filter( 'woocommerce_get_related_product_cat_terms', 'exclude_brands_from_related' );
    

    However it doesn’t appear to work with WooCommerce 3.2.

    Any help would be greatly appreciated!

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude Categories from Related Products’ is closed to new replies.