Try our conversational search powered by Generative AI!

Retrieve best discount price when multiple discounts are valid


Commerce version 12.5.0

Hi All,

I thought that when retrieving discount prices the best price was retrieved first if multiple discounts were valid.

For example.  I have two discounts, one where a 15% discount is applied when the logged in user is within a "staff" role (setup via a visitor group) and another discount which is just 20% across all categories.  These are both setup so they can't be combined. The 15% is currently set as higher priority.

I would have expected that since 20% is a better price this is retrieved, however that doesn't appear to be the case, 15% is.

When I call "GetDiscountedPrices" I only see the 15% price, however if I remove the "Combined" setting and call again I see both prices (so I can order these and get the lowest first), however the 15% is applied and then the 20% is applied on top so the price isn't correct.

Is there a way around this behaviour?

I've seen some related discussion on

        protected virtual IEnumerable GetDiscountedPrices(ContentReference contentLink, IMarket market, Currency currency)
            return _promotionEngine.GetDiscountPrices(new[] { contentLink }, market, currency, _referenceConverter, _lineItemCalculator);


Sep 27, 2018 3:50

Hi. Mark. shouldn't the 20% discount have higher priority ?

Sep 27, 2018 5:51

I've simplified my scenario as there will be lots of discounts created via the api and I think trying to manage priority across all won't be possible.

Sep 27, 2018 5:59

So let me rephrase it: you want to have multiple/many promotions, but always only one promotion with best discount is applied? Is it per order or per item?

Sep 27, 2018 9:39

Hi Quan, Correct, It would be per item. Cheers Mark

Sep 27, 2018 9:46

Then it would be very very tricky to do. If you want to have it per order - then what you can do is to use Evaluate to find out which promotion gives the best discount and then apply that. When it comes to per item ... One half-baked way to do is to call Evaluate on each item to find out which promotion is the best. However, that will not work with some discounts like "Buy $100 get 20% discount on selected items".

TL;DR: your requirement is very unique and I'm afraid it can not be done easily (if at all) with the promotion system. 

Sep 27, 2018 9:53

Ok thanks for the feedback Quan. I've put in place some code to set the priority when discounst are created, will have to see how that goes as we get into more real world testing.

Sep 28, 2018 4:07
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.