从WooCommerce中排除相关产品的特定产品类别

时间:2017-10-24 15:08:24

标签: php wordpress woocommerce

我们为类型和品牌使用WooCommerce产品类别,但是希望从相关产品中删除类型类别,并展示同一品牌的类别。

我们找到了这个解决方案:

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' );

然而,它并不适用于WooCommerce 3.2。

非常感谢任何帮助!

0 个答案:

没有答案
相关问题