Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zackeryfretty/daf91fcc139716ebeabfe0d5d99d51ff to your computer and use it in GitHub Desktop.
Save zackeryfretty/daf91fcc139716ebeabfe0d5d99d51ff to your computer and use it in GitHub Desktop.
<?php
add_filter( 'woocommerce_dynamic_pricing_process_product_discounts', 'is_product_eligible', 10, 4 );
function is_product_eligible( $eligible, $product, $discounter_name, $discounter_object ) {
// Remove Filter
remove_filter( 'woocommerce_dynamic_pricing_process_product_discounts', 'is_product_eligible', 10, 4 );
// Get Cart
$cart = WC()->cart;
// Look for 'COUPON-NAME' in array
if(in_array('COUPON-NAME', $cart->applied_coupons)):
// If Found, Disable Dynamic Pricing
$eligible = FALSE;
endif;
// Add Modded Filter
add_filter( 'woocommerce_dynamic_pricing_process_product_discounts', 'is_product_eligible', 10, 4 );
return $eligible;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment