Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save AshlinRejo/24bd342db913580fd06e97109914df72 to your computer and use it in GitHub Desktop.
Save AshlinRejo/24bd342db913580fd06e97109914df72 to your computer and use it in GitHub Desktop.
Discount Rules v2: Exclude the Composite product item(WPClever) from discount
add_filter('advanced_woo_discount_rules_calculate_discount_for_cart_item', function ($calculate_discount, $cart_item){
if(isset($cart_item['wooco_parent_key']) && !empty($cart_item['wooco_parent_key'])){
$calculate_discount = false;
}
return $calculate_discount;
}, 100, 2);
add_filter('advanced_woo_discount_rules_include_cart_item_to_count_quantity', function($take_count, $cart_item){
if(isset($cart_item['wooco_parent_key']) && !empty($cart_item['wooco_parent_key'])){
$take_count = false;
}
return $take_count;
}, 100, 2);
add_filter('advanced_woo_discount_rules_process_cart_item_for_cheapest_rule', function($calculate_discount, $cart_item){
if(isset($cart_item['wooco_parent_key']) && !empty($cart_item['wooco_parent_key'])){
$calculate_discount = false;
}
return $calculate_discount;
}, 100, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment