UnitPrice.Value of orderline missing in DiscountRewardContext
Hi Matt,
We have created a discount reward for a custom discount rule that we use in a webshop.
In this custom reward we overwrite the CalculateReward method to calculate DiscountAdjustments and add them to the DiscountRewardCalculation.
This method is called twice, when recalculating the order price.
During the first time, the UnitPrice.Value of an orderline (e.g. (DiscountRewardContext) context.OrderLines[0].UnitPrice.Value) is filled with an object. (We use this one to calculate a new price for the DiscountAdjustment based on an orderline)
But when this method is called again, the UnitPrice.Value of all orderlines is missing and returns null.
Therefore we cannot calculate the correct discount.
UnitPrice.Value of orderline missing in DiscountRewardContext
Hi Matt,
We have created a discount reward for a custom discount rule that we use in a webshop.
In this custom reward we overwrite the
CalculateReward
method to calculateDiscountAdjustments
and add them to theDiscountRewardCalculation
.This method is called twice, when recalculating the order price. During the first time, the
UnitPrice.Value
of an orderline (e.g. (DiscountRewardContext)context.OrderLines[0].UnitPrice.Value
) is filled with an object. (We use this one to calculate a new price for theDiscountAdjustment
based on an orderline)But when this method is called again, the UnitPrice.Value of all orderlines is missing and returns null. Therefore we cannot calculate the correct discount.
Is it supposed to return null sometimes?
Umbraco version: 8.18.0
Vendr version: v2.1.1
Hi Maikel,
You might want to read the docs around the calculation state https://vendr.net/docs/core/2.1.0/umbraco-v9/key-concepts/order-calculation-state/ as during a calculation prices are temporarily stored in another object.
I think updating to 2.1.3 might also help here as we did some work in that release to set some values temporarily https://vendr.net/docs/core/changelog/#v213
I think the calculation state is key here though.
Hope that helps
Matt
Using the
IOrderLineCalculator
worked.Thanks, for the quick reply!
is working on a reply...