Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lucasstark/1bac208857c6d1e713455f11943f65c6 to your computer and use it in GitHub Desktop.
Save lucasstark/1bac208857c6d1e713455f11943f65c6 to your computer and use it in GitHub Desktop.
Disable Dynamic Pricing with Coupon
add_filter( 'woocommerce_dynamic_pricing_process_product_discounts', 'dynamic_pricing_is_product_eligible', 10, 1 );
function dynamic_pricing_is_product_eligible( $apply ) {
//Change these to the codes that should disable dynamic pricing. Add or remove as needed.
$coupon_codes = array(
'cart discount',
'another code',
'third code'
);
foreach ( WC()->cart->get_applied_coupons() as $applied_coupon ) {
if ( in_array( $applied_coupon, $coupon_codes ) ) {
$apply = false;
}
}
return $apply;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment