Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Maikel 5 posts 96 karma points
    May 10, 2022 @ 12:14
    Maikel
    0

    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.

    Is it supposed to return null sometimes?

    Umbraco version: 8.18.0
    Vendr version: v2.1.1

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    May 10, 2022 @ 13:07
    Matt Brailsford
    100

    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

  • Maikel 5 posts 96 karma points
    May 10, 2022 @ 14:38
    Maikel
    0

    Using the IOrderLineCalculator worked.

    Thanks, for the quick reply!

Please Sign in or register to post replies

Write your reply to:

Draft