I came across this in a client site after updating to latest coupon and discount modules.

I managed to replicate on a clean kickstart2 install with the coupon and discount modules updated to latest.

- Create some coupon based product % off discounts with "This discount is not compatible with any other discount."

I only have 2 active coupons both set to "This discount is not compatible with any other discount" if I repeatedly add both coupon codes they switch (as I would expect, although on a live site i can just add them) but then both get applied (see attached from clean kickstart2 and live client site).

This does not appear to affect order based discounts, I cant add two coupons - only product based discounts.

Im no good at coding but happy to test any fixes on my clean test install...

Ive created an issue on the discount issue page regarding % product based discounts with not compatible to any others set (no coupon) not showing in the cart if coupon discounts are active (but not applied) - not sure if both issues are interlinked? https://www.drupal.org/node/2617998

Just to re-iterate - seems to only be an issue with product % based discounts not order based.

Many thanks for the latest versions as they are much more stable and flexible - great to be able to create a coupon based discount in one go/one screen..

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kevster created an issue. See original summary.

kevster’s picture

Bumping this as its still an issue meaning live client site has multiple coupons that can be added to cart and customers can potentially buy products at hugely discounted rates if they know enough coupon codes...

kevster’s picture

Priority: Normal » Major
kevster’s picture

This is still an issue - live client site customers can add multiple coupons altho set to not compat?

Shopping cart contents
Product SKU Price Quantity Weight Total
Ring Size Set A - Z + 6 TR64A £14.50 1 0.2 kg £14.50
Subtotal £14.50
ACJTAM coupon -£1.17
MJN123 coupon -£1.31
10% Student Discount -£1.45

VAT £2.11
Order total £12.68

torgosPizza’s picture

Title: multiple coupons applied even though not compat with set on all » Compatibility settings not honored with multiple coupons, allowing multiple discounts on order
Project: Commerce Coupon » Commerce Discount
Version: 7.x-2.0-rc2 » 7.x-1.x-dev
Issue tags: +commerce-sprint

Changing title and tagging, and moving to Commerce Discount.

torgosPizza’s picture

@kevster: Can you try this without coupons on the discounts? I'm interested to see if this is a Discounts issue or if it only happens when the discounts have a Coupon attached. Because if that's the case (no coupons = proper discount situation) then it means more likely an issue with Commerce Coupon.

kevster’s picture

Hi @torgosPizza - will try this today and report back - thanks...

EDIT:
Ok so I removed the coupons from my existing coupon discounts (ran drush cc all), now have:
5% off discount not compat with any other (order level)
20% off discount not compat with any other (order level)
10% off discount not compat with any other (product level)

All have a default weight of 10
1. SET ALL DISCOUNTS TO:
This discount is not compatible with any discount

When I check out I get the 5% off order level one and the 10% off product level (20% off doesnt show)

When I check the order there are no discounts showing and I have been charged full price, customer email shows no discounts applied

2. SET ALL DISCOUNTS TO
This discount is compatible with any discount except the selected discounts and add all other discounts.
check out and only shows
10% off discount not compat with any other (product level) which i think is the last discount of the 3 that I created
I see the discount applied in admin orders and email confirms I get the discount ok

3. SET ALL DISCOUNTS TO
This discount is compatible with any other discount.
check out and shows all 3 discounts
I see all the discounts applied in admin orders and email confirms I get the discounts ok

Any more testing you need please shout, I'll try and jump on it quicker next time.

Appreciate the help...

joelpittet’s picture

Considering hiding this feature due to complexity/bugs it introduced.

#2632072: Move compatibility feature to optional experimental feature

kevster’s picture

hi @joelpittet - I think this is a good idea as it doesnt work right now. For now Im using option 2 above which although can get messy with lots of discounts - it does work...

kevster’s picture

hi @joelpittet - any news on this one as to a fix or if its been hidden?

joelpittet’s picture

Assigned: Unassigned » rszrama

I'm waiting on @rszrama to chime in as he added that feature in. Don't want to step on toes.

kevster’s picture

Ok thx @joelpittet..

Hi @rszrama any chance you can chime in please as im getting chased by a client - hopefully my test info on a clean install above will help verify the issue...

ordermind’s picture

Here's a patch that solves this problem and also provides working compatibility conditions for product discounts so that list prices take discount compatibility into account. Please note that no update hook is provided in the patch for updating existing rules but clearing the cache will update all discount rules that are served by code. If you have overwritten a discount rule it will not be updated.

maseyuk’s picture

Thanks @ordermind that seemed to do the trick for me

hugronaphor’s picture

Yes! The @ordermind 's solution works.
This was messing up the whole Price component in my project. We need this committed.

Now we need to run an update path?

torgosPizza’s picture

I'll test this as well - I'd love to be able to mark it as RTBC!

rszrama’s picture

Interessant. Will give it a look ASAP.

hugronaphor’s picture

In the main time, I discovered two more problems:

having:
- A discount with "Discount compatibility" set to "Not with any other discounts" (fot whole product type) - global_discount_10_percent
- A discount applied to a specific product compatible with others - nivea_crem

1. The discount "global_discount_10_percent" has to be created at the very beginning before adding other (compatible with other) discounts because If re-saving global_discount_10_percent it will take the priority immediately on all another discount. I checked commerce_discount_compatibility_check_line_item() and nivea_crem don't even arrive here to be checked, only global_discount_10_percent is coming.

2. The order has to be maximal. Otherwise it's just ignored while I would expect that a discount with "Discount compatibility" set to "Not with any other discounts" shouldn't care about the execution order.

IckZ’s picture

Hey everyone,
I've tested the patch above but nothing changed.

My Setup:
- a product discount which is applied if a product-field-value is set to "outlet = true"
- a 10% order discount

The 10% order discount should not be accepted if one or more products have the (outlet) product discount. Did I miss something or is this not possible?

czigor’s picture

Status: Needs review » Closed (duplicate)

I can't reproduce the original issue with the patch in #2621526: Compatibility settings other than "all" causes Discount+Coupon to be removed. So marking this as duplicate. If you disagree, please provide steps to reproduce the issue you're experiencing.