Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › composite products count › Reply To: composite products count
December 8, 2022 at 10:43 pm #19427
Soft79
Keymaster
I’m not sure if this will work, this snippet will not count products of which the price is 0. Replace ‘my_coupon_code’ with the actual coupon code. If this snippet doesn’t do anything please send the snippet to the author of the Composite Product plugin and ask how we can detect that it’s a ‘child’-product of a composite product. Maybe the $values array contains an item that tells us the item is part of a composite product.
add_filter(
'woocommerce_coupon_is_valid_for_product',
function ( $valid, $product, $coupon, $values ) {
if ( $coupon->get_code() === 'my_coupon_code' && $product->get_price() == 0 ) {
$valid = false;
}
return $valid;
}, 10, 4
);