Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Discount rules: Skip an item from calculating subtotal for price rules
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
You can’t perform that action at this time.