Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This module is very close to what I'm looking for, but my business logic is a fraction different. Rather than applying the coupon when any one of the referenced products is in the cart, I need the coupon to only apply when all of the referenced products are in the cart. Can you suggest a way to achieve this? (e.g. does it require a whole new condition instead of list_contains_item?)
Comments
Comment #1
AndyF CreditAttribution: AndyF commentedHi,
There's a couple of ways that might work I think. Without coding you could try:
Alternatively with coding you could create a new condition, something like Order contains all products referenced by the coupon. You'd then just use that instead of Order contains a product that is referenced by the coupon in Coupon Validation: Check the referenced products.
If you took the latter approach, I'd happily add the new condition to the module.
HTH
Comment #2
jonathan_hunt CreditAttribution: jonathan_hunt commentedThanks for the response. I've experimented with this and AFAICT any solution that relies on Validate a coupon is flawed because it only occurs when the coupon is first applied. If I apply a coupon and subsequently alter the cart (i.e. remove a referenced product) the coupon still applies to the remaining product.
I started writing a new condition "commerce_couponprodref_order_has_all_referenced_products". I thought I could add it as a condition in the rule "Apply percentage coupons to referenced product line item" but although I can reference the Order in the conditions, I can't seem to select the Coupon as an entity in the Data selector...
Comment #3
AndyF CreditAttribution: AndyF commentedAh, didn't know that! What exactly are you looking for: do you want the coupon removed from the order as soon as a key product is removed? I think that could be done with Rules by using the event after removing a product from cart and effectively doing the validation again at this point.
I haven't taken a look as I'm a bit snowed under :/ but have you used an entity has field condition to bring the coupon into scope?
Comment #4
AndyF CreditAttribution: AndyF commented