Created
December 3, 2019 08:02
-
-
Save AshlinRejo/5a07d3f47dd9cd71e0823d506a0c128b to your computer and use it in GitHub Desktop.
Discount rules: Skip an item from calculating subtotal for price rules
This file contains 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_skip_item_to_calculate_subtotal_for_price_rules_free_products($include_item, $cart_item, $rule){ | |
$product_ids_to_exclude = array(10, 24);//ENTER THE PRODUCT IDS to exclude from calculating subtotal | |
if(isset($cart_item['data']) && !empty($cart_item['data'])){ | |
$_product = $cart_item['data']; | |
$product_id = $_product->get_id(); | |
if(in_array($product_id, $product_ids_to_exclude)){ | |
$include_item = false; | |
} | |
} | |
return $include_item; | |
} | |
add_filter('woo_discount_rules_skip_item_to_calculate_subtotal_for_price_rules', 'woo_discount_rules_skip_item_to_calculate_subtotal_for_price_rules_free_products', 10, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment