Try our conversational search powered by Generative AI!

Promotion calculation error after upgrading Commerce


We're on our way to upgrade EPiServer Commerce from to and are experiencing some problems with promotion calculations for order discounts (item discounts seems to be working as before). Totals and Subtotals differ, amongst other. I can't find any breaking change regarding this other than a blog post (which is subject to changes);

"Order Calculator Changes: Some default calculator implementations don't work as expected, for example they include order level discounts in the subtotal instead of the order total."

Could this be related to our issue and is the above implemented in the final release? 

Apr 23, 2018 9:59

If you can post your promotion configuration, and the differences between 10.8 and 11.8.3, it would help us looking into this. 

Apr 23, 2018 10:39

The promotion configuration is the same in both version, "Buy at least X items from catalog entries and get discount on order value." i.e. buy any product and get 15% off on the order.

But to your knowledge, is there something that has changed regarding the discount calculation on item-level (works in both our versions) vs. on order-level (does not work in our 11.8.3)? We have some custom calculators (CustomTaxCalculator, CustomShippingCalculator, CustomOrderGroupCalculator) which could be subject to change if so. For example in our CustomOrderGroupCalculator we override the CalculateTotal of DefaultOrderGroupCalculator like so:

protected override Money CalculateTotal(IOrderGroup orderGroup)
            var total = this.GetSubTotal(orderGroup) + this.GetHandlingTotal(orderGroup) + 
                this._shippingCalculator.GetShippingCost(orderGroup, orderGroup.Market, orderGroup.Currency) + 
                this._taxCalculator.GetTaxTotal(orderGroup, orderGroup.Market, orderGroup.Currency);

            var roundedTotal = total.Amount.RoundSis(total.Currency);
            return new Money(roundedTotal, total.Currency);

if I include removal of the OrderDiscountTotal (this.GetOrderDiscountTotal(orderGroup, orderGroup.Currency)) from the total variable above, it seems to add up to the correct values. I suppose it's not the right way to solve this problem but maybe a hint to what the issue could be(?)

Edited, Apr 23, 2018 12:43

I discussed with my colleagues and it seems the changed behavior is from COM-2434 GetSubTotal methods use ExtendedPrice instead of DiscountedPrice. This is a sematic breaking change in Commerce 11 so we might have missed documenting it. I'll check with documentation team to add such information. Thanks for notifying us and apologies for the inconveniences. 

Apr 23, 2018 13:26

I'm not quite sure I follow, should I solve the problem like suggested above by removing the OrderDiscountTotal from CalculateTotal?

Apr 23, 2018 14:51

From what I can tell, the new implementation of CalculateTotal takes the OrderDiscountTotal into account (it minuses the value returned by GetOrderDiscountTotal) before returning the result. I guess you would have to do the same in your custom implementation.

Apr 23, 2018 15:10

Ok great, thanks a lot for the quick response!

Apr 23, 2018 15:11
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.