November Happy Hour will be moved to Thursday December 5th.

NullReferenceException in OrderFormPriceMatrix

Vote:
 

Hi,

I have a Software catalog and a Training catalog in Commerce. If I try to apply a coupon code on an order that contains a Training catalog product, I get a NullReference error in the internal OrderFormPriceMatrix.CalculateAndCommit method. It's not easy to debug because it's all internal EPi code but I found out that the error occurs on this code line:

IEnumerable<PriceEntry> enumerable = item.DiscountRange();

The item variable is NULL because the ExtractEntities method in OrderFormMatrix class returns NULL. Any idea why this is happening?

And to make it even more mysterious: the problem does NOT occur if my order only contains Software catalog products. Coupon codes are working as expected in that case:-)

MY STACKTRACE:

at EPiServer.Commerce.Marketing.OrderFormPriceMatrix.CalculateAndCommit(AffectedEntries item, Func`3 apply)
at EPiServer.Commerce.Marketing.OrderRewardApplicator.ApplyDiscount(AffectedOrder item, Decimal discountAmount, PromotionProcessorContext processorContext)
at EPiServer.Commerce.Marketing.RewardApplicatorBase`1.<>c__DisplayClass1_0.<Apply>b__0(TAffectedObject item)
at EPiServer.Commerce.Marketing.RewardApplicatorBase`1.ForEach(Func`2 apply, IEnumerable`1 affectedItems)
at EPiServer.Commerce.Marketing.RewardApplicatorBase`1.Apply(RewardDescription reward, RedemptionDescription redemption, PromotionProcessorContext processorContext)
at EPiServer.Commerce.Marketing.RewardApplicatorBase`1.Apply(RewardDescription reward, Int32 remainingRedemptions, PromotionProcessorContext processorContext)
at EPiServer.Commerce.Marketing.PromotionEngine.ApplyReward(RewardDescription rewardDescription, PromotionFilterContext promotionFilteringResult, PromotionExclusionHandler exclusionHandler, PromotionData promotion, PromotionProcessorContext processorContext)
at EPiServer.Commerce.Marketing.PromotionEngine.Run(IOrderGroup orderGroup, PromotionEngineSettings settings)
at EPiServer.Commerce.Order.IOrderGroupExtensions.ApplyDiscounts(IOrderGroup orderGroup, IPromotionEngine promotionEngine, PromotionEngineSettings settings)
at EPiServer.Commerce.Order.IOrderGroupExtensions.ApplyDiscounts(IOrderGroup orderGroup)
at Mediachase.Commerce.Workflow.Activities.CalculateDiscountsActivity.Execute(ActivityExecutionContext executionContext)
at Mediachase.Commerce.WorkflowCompatibility.Activity.Execute()
at Mediachase.Commerce.Engine.ActivityFlowRunner.<>c__DisplayClass15_0`1.<Do>b__0()
at Mediachase.Commerce.Engine.ActivityFlowRunner.Execute()
at Mediachase.Commerce.Engine.ExecutionManager.ExecuteActivityFlow(String name, ActivityFlowContext context)

#207205
Sep 12, 2019 16:15
Vote:
 

Have you defined any specific condition on your promotion that you can only apply this promotion on a particular type of items? Can you post promotion details here?

#207327
Sep 17, 2019 9:39
Vote:
 

Hi,

No I haven't defined any specific conditions. You can see my promotion details here: https://drive.google.com/file/d/1_WcNxsr9oE6-ZsEw9VDDG-sC9PTRjfEG/view

#207336
Sep 17, 2019 10:48
* 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.