Php 从商业中的相关产品中排除特定产品类别
我们对类型和品牌使用WooCommerce产品类别,但是我们希望从相关产品中删除类型类别,只展示相同品牌的产品 我们找到了这个解决方案:Php 从商业中的相关产品中排除特定产品类别,php,wordpress,woocommerce,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 =
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
任何帮助都将不胜感激