Created
October 4, 2019 12:36
-
-
Save rameshelamathi/67ed38c5e600bc8c0d323bd1e9900a79 to your computer and use it in GitHub Desktop.
Product Type as Categories for Woo Discount Rule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function woo_discount_rules_accepted_taxonomy_for_category_method($taxonomy){ | |
$taxonomy[] = 'product_type'; | |
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){ | |
$taxonomy_to_apply = 'product_type'; | |
$tags = get_the_terms( $product_id, $taxonomy_to_apply ); | |
if(isset($tags) && (is_object($tags) || is_array($tags)) && count($tags) > 0) { | |
foreach ($tags as $tag){ | |
$categories[] = $tag->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