Support Woocommerce Brands - Brands loads in category while create rules
Ensure compatibility with Woocommerce Brands, loading brands in categories when creating rules.
function woo_discount_rules_accepted_taxonomy_for_category_method($taxonomy){
$taxonomy[] = 'product_brand';
return $taxonomy;
}
add_filter('woo_discount_rules_accepted_taxonomy_for_category', 'woo_discount_rules_accepted_taxonomy_for_category_method', 10);
function woo_discount_rules_load_additional_taxonomy_method($categories, $product_id){
$brands = get_the_terms( $product_id, 'product_brand' );
if(!empty($brands)){
foreach ($brands as $brand){
$categories[] = $brand->term_id;
}
}
return $categories;
}
add_filter('woo_discount_rules_load_additional_taxonomy', 'woo_discount_rules_load_additional_taxonomy_method', 10, 2);