Skip to content

Instantly share code, notes, and snippets.

@rameshelamathi
Created October 4, 2019 13:20
Show Gist options
  • Save rameshelamathi/e11ff1c8f6c51631d0789176d16838f8 to your computer and use it in GitHub Desktop.
Save rameshelamathi/e11ff1c8f6c51631d0789176d16838f8 to your computer and use it in GitHub Desktop.
Apply discount only for downloadable product
function woo_discount_rules_exclude_cart_item_from_discount_method($skip, $cart_item){
$product_ids_to_exclude = array();
if(is_object($cart_item['data']) && method_exists($cart_item['data'], 'is_downloadable')) {
if(!$cart_item['data']->is_downloadable()) {
$skip = true;
}
}
return $skip;
}
add_filter('woo_discount_rules_exclude_cart_item_from_discount', 'woo_discount_rules_exclude_cart_item_from_discount_method', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment