Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function woo_discount_rules_exclude_cart_item_from_discount_method($excluded_products, $rule, $variants){
- $eligible_rule_id = 9999; // enter the rule ID that applies for downloadable product only
- if(isset($rule->ID) && $rule->ID == $eligible_rule_id ) {
- $query = new WC_Product_Query( array(
- 'downloadable' => false,
- 'return' => 'ids',
- ) );
- $products = $query->get_products();
- if(!empty($products) && is_array($products) && count($products)) {
- $all_products_to_exclude = array_merge ($excluded_products, $products);
- foreach($all_products_to_exclude as $product_id) {
- $product_ids_to_exclude[] = intval($product_id);
- }
- $excluded_products = $all_products_to_exclude;
- }
- }
- return $excluded_products;
- }
- add_filter('woo_discount_rule_products_to_exclude', 'woo_discount_rules_exclude_cart_item_from_discount_method', 10, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement