Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Promotion calculation error after upgrading Commerce

Vote:
 

We're on our way to upgrade EPiServer Commerce from 10.8.0.0 to 11.8.3.0 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); https://world.episerver.com/blogs/Magnus-Rahl/Dates/2017/2/planned-breaking-changes-in-commerce-2017/

"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? 

#191168
Apr 23, 2018 9:59
Vote:
 

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

#191170
Apr 23, 2018 10:39
Vote:
 

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(?)

#191174
Edited, Apr 23, 2018 12:43
Vote:
 

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. 

#191176
Apr 23, 2018 13:26
Vote:
 

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

#191179
Apr 23, 2018 14:51
Vote:
 

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.

#191181
Apr 23, 2018 15:10
Vote:
 

Ok great, thanks a lot for the quick response!

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