Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AshlinRejo/5a07d3f47dd9cd71e0823d506a0c128b to your computer and use it in GitHub Desktop.
Save AshlinRejo/5a07d3f47dd9cd71e0823d506a0c128b to your computer and use it in GitHub Desktop.
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