Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Attempted to divide by zero CalculateDiscountsActivity



After upgrading from Commerce 8.15 to 9.8.1

I do get "Attempted to divide by zero" error on CartPrepair and CartCheckOutWorkflow (ApplyItemDiscount in CalculateDiscountsActivity), The error is when i have a promo 100% of order value. 

This is suppose to be fixed in version 8.2 and it seems that i don't have this problem in version 8.15.

Any work around or configuration that i'm missing?

Should i implement my own CalculateDiscountsActivity?

MetaInfo: Some product skus may not have any price at all


Feb 22, 2016 14:29


It's unsual to have SKUs without price. I think the problem comes from this (ApplyItemDiscount in CalculateDiscountsActivity):

// Calculate percentage off discount price
if (totalAmount > 0)
    percentageOffTotal = record.PromotionReward.AmountOff / totalAmount;
    // but since CostPerEntry is not an adjusted price, we need to take into account additional discounts already applied
    percentageOffTotal = percentageOffTotal * (totalAmount / record.AffectedEntriesSet.TotalCost);
    percentageOffTotal = 100m;
discountAmount = record.PromotionReward.AmountOff;

In your certain cases record.AffectedEntriesSet.TotalCost can be 0 and cause the problem.

You don't have to implement your own CalculateDiscountsActivity, just download the source code package, build it, debug and the fix it.



Feb 22, 2016 16:18

Allright, i integrated Mediachase.Commerce.Workflow into our solution and made some customization. I guess i need to be awaik if Episerver updates this package then...  

Feb 24, 2016 14:49
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.