Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Kowsaliya
Created February 20, 2019 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kowsaliya/85985e5478d1e4a713a6944800ebeaa8 to your computer and use it in GitHub Desktop.
Save Kowsaliya/85985e5478d1e4a713a6944800ebeaa8 to your computer and use it in GitHub Desktop.
Woo Discount Rules: Support Perfect Woocommerce Brands - Brands loads in category while create rules
function woo_discount_rules_accepted_taxonomy_for_category_method($taxonomy){
$taxonomy[] = 'pwb-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, 'pwb-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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment