Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sarancartrabbit/ad8c86a27ce3a9e6990808adcc84bdfb to your computer and use it in GitHub Desktop.
Save sarancartrabbit/ad8c86a27ce3a9e6990808adcc84bdfb to your computer and use it in GitHub Desktop.
Woo Discount Rules v2 - Check customized coupon based disable the discount rule
add_filter('advanced_woo_discount_rules_filter_passed', function($filter_passed, $rule, $product, $sale_badge){
$coupon_applied = in_array('your_coupon_code', WC()->cart->get_applied_coupons());
//'array(1,2)' - give rule id as you needed
if(in_array($rule->getId(), array(1, 2)) && $coupon_applied){
// Add your additional condition here if required
// Your custom logics enter here and return true or false
// true -> Run rule
// false -> Do not run rule
return true;
}
return $filter_passed;
}, 10, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment