Promotion engine calculates discount prices from the wrong default price

Member since: 2012

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?

#179717 Jun 20, 2017 12:11
  • Member since: 2016

    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.

    #179737 Jun 20, 2017 16:06
  • Member since: 2012

    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.

    #179738 Jun 20, 2017 16:11
  • Member since: 2011

    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.

    #179739 Jun 20, 2017 16:20
  • Member since: 2012

    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.

    #179741 Jun 20, 2017 16:23
  • Member since: 2011

    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. 

    #179743 Jun 20, 2017 16:36
  • Member since: 2016

    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.

    #179744 Jun 20, 2017 16:38
  • Member since: 2012

    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.

    #179745 Jun 20, 2017 16:39
  • Member since: 2016

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

    #179746 Jun 20, 2017 16:40
  • Member since: 2011

    I think this should be what you are looking for.

    https://world.episerver.com/blogs/Shannon-Gray/Dates/2016/11/promotion-engine-sale-price-customization/

    #179762 Jun 21, 2017 2:05
  • Member since: 2012

    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.

    #179777 Jun 21, 2017 15:05