Try our conversational search powered by Generative AI!

Retrieve best discount price when multiple discounts are valid

Vote:
 

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 https://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=187959&pageIndex=1

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



Thanks
Mark

#197250
Sep 27, 2018 3:50
Vote:
 

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

#197252
Sep 27, 2018 5:51
Vote:
 

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.

#197253
Sep 27, 2018 5:59
Vote:
 

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?

#197268
Sep 27, 2018 9:39
Vote:
 

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

#197269
Sep 27, 2018 9:46
Vote:
 

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. 

#197270
Sep 27, 2018 9:53
Vote:
 

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.

#197291
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.