Try our conversational search powered by Generative AI!

Promotion engine calculates discount prices from the wrong default price


I have two prices for the product:

One price has minimum quantity 0 and the second - 1.

When I call a promotion engine's method GetDiscountPrices, it calculates the discount from the first price.

var discountedPrice = _promotionEngine.GetDiscountPrices(new[] { entry.ContentLink }, market, currency, _referenceConverter, _lineItemCalculator);

It is wrong because there will be no way for the user to buy 0 amount of the product. Minimum quantity all promotions should calculate the price from should be 1. It really confuses customers that they see one price on the product page, but when they put the product in the cart, they get discounted price.

Is there a built-in way to override this behavior?

Jun 20, 2017 12:11

A user can buy less than 1 quantity since it's a decimal, you can implement having added something with 0.5 qty in the cart. Sure, most often it's an integer value of the quantity in our implementatios, but the promotion engine can't know this.

Jun 20, 2017 16:06

That's a good point.

But is there a way to override this behavior? When using a price service, and I am looking for prices I can set quantity I want. It'd be nice if same could be applied for promotion engine.

Jun 20, 2017 16:11

My question is why would you want both 0 and 1 MinQuantity prices? Without the promotion, what is the price the customer will get when they add the item to the cart?

The default price is always the price with Quantity = 0. If you want to change the behavior, implement your own ReadOnlyPricingLoader and override GetDefaultPrice to ask IPriceService to return price (with quantity) you want to.

Jun 20, 2017 16:20

The price with 0 is a price we display a user as an "initial" price while the price with 1 is an actual sale price.

Now when a customer adds an item to the cart, it gets discount correctly.

Jun 20, 2017 16:23

Not saying that's wrong, but it's different with how Episerver "sees" the price. As a framework it has to care about decimal quantity - as Joel said - and 0 is the default minimum quantity. Yours is a different way of using minimum quantity and this can conflict with other parts of the framework.

So you can do like I mentioned, or you can use special sale code (like "MSRP") for storing "initial" price. Both will have minimal quantity = 0, and the promotion system will only care about the default price without sale code. 

Jun 20, 2017 16:36

The use case is pretty common and as far as I know there is no native support for it in Commerce. We've solved it by hacking around with different price entries with different combination of sale type/sale code (or customertype), since we don't use that feature.

Jun 20, 2017 16:38

Thanks, Quan! Probably it is the way to go (just have to rework a lot :) ). It did work before we started to use promotions which can be applied to the products not added to the cart yet.

Jun 20, 2017 16:39

But that's for a B2C site, I think you'd want to use it differently for a B2B site.

Jun 20, 2017 16:40

I think this should be what you are looking for.

Jun 21, 2017 2:05

I do believe you are making it much harder for yourself.

The promotion engine uses IPriceService.GetDefaultPrice for it's calculations.

All you have to do it implement your own IPriceService and register it and you are all set.

Making it a decorator of the standard implementation and just override the GetDefaultPrice function will mean a minmum of code.

Jun 21, 2017 15:05
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.