WooCommerce coupon settings allow you to define allowed products (or product categories). What’s missing, however, is the other way around: how to set up a product so that it can never be discounted?

Thankfully, a handy WooCommerce filter comes to the rescue (“woocommerce_coupon_is_valid_for_product“) and we can therefore make all coupons “invalid” when a given product is in the cart. Enjoy!

Here’s what happens

PHP Snippet: Disable All Coupons for a Single Product ID @ WooCommerce Cart / Checkout Page

/**
 * @snippet       Exclude Product From All Coupons - WooCommerce
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 5.1
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */
 
add_filter( 'woocommerce_coupon_is_valid_for_product', 'bbloomer_exclude_product_from_product_promotions_frontend', 9999, 4 );

function bbloomer_exclude_product_from_product_promotions_frontend( $valid, $product, $coupon, $values ) {
   // PRODUCT ID HERE (E.G. 12345)
	if ( 12345 == $product->get_id() ) {
		$valid = false;
	}
	return $valid;
}
Share:

Leave a Reply