Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sarancartrabbit/5e5f00cd7fda68537f949123d69a8124 to your computer and use it in GitHub Desktop.
Save sarancartrabbit/5e5f00cd7fda68537f949123d69a8124 to your computer and use it in GitHub Desktop.
Discount rules v2: To check the parent category in the product
if(!function_exists('awdrcheckParentCategory')){
function awdrcheckParentCategory ($categories){
foreach($categories as $id) {
if ($term = get_term($id)) {
if ($parent_id = $term->parent) {
if (!in_array($parent_id, $categories)) {
$categories = array_merge($categories, awdrcheckParentCategory(array($parent_id)));
}
}
}
}
return array_unique($categories);
}
add_filter('advanced_woo_discount_rules_get_product_categories','awdrcheckParentCategory', 10, 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment