I am trying to exclude some product variations that have specific product attributes from coupon discounts.
In my case I am targeting product variations that have a product attribute “finish” set to “Classic Frame” or “Box Frame” term.
I tried to use “Exclude variations with 2 specific attribute terms from coupon usage in Woocommerce“ answer code and it does indeed make the coupon invalid when a product variation has a product attribute “finish” set to “Classic Frame” or “Box Frame” term.
But it also makes the coupon invalid for any other items added to the cart.
So for example if the cart has 3 items in it:
- Item 1: has the attribute “Classic Frame” ==> Coupon is Not Valid for this Item
- Item 2: has the attribute “Box Frame” ==> Coupon is Not Valid for this Item
- Item 3: has the attribute “Loose” ==> Coupon should be VALID for this Item
So what I would like is that the coupon discount is only applied to other items.
Any help is really appreciated.
2
Answers
The purpose of “Exclude variations with 2 specific attribute terms from coupon usage in Woocommerce“ answer code is to make a coupon invalid if there is any product variation that has ‘Classic Frame’ or ‘Box Frame’ term set for ‘Finish’ product attribute (for variations).
Yes it makes the coupon invalid, even if there is other items without it, and it’s the right behavior.
Maybe a commercial plugin exist that extends coupon possibilities, allowing to exclude product variations IDS (adding a usable filter hook) to that extended feature.
You can use this filter