Copied to clipboard

Flag this post as spam?

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


  • Jeffrey Veer 41 posts 308 karma points
    May 01, 2023 @ 14:55
    Jeffrey Veer
    0

    Base Price PriceAdjustment not persisted

    Hi,

    We are currently working on a discount on the base price, for which we are using the PriceAdjuster. This all works fine, except that the adjustments we add on the BasePrice aren't persistent when the order is finalized.

    The price adjustments are working fine when it's still on a cart, we can see the prices correctly in Vendr and our frontend. When we finalize the order, the transaction amount is also with the adjusted base price.

    When debugging in the code we found that a check is done in the ApplyOrderPriceAdjustmentsTask which only adds the adjustments on a base price if the order line is a BundleOrderLineReadOnly.

    Is it intentional that the base price adjustments only work on bundles?

    We are using Vendr 3.0.11

    If you need any more information, please let me know and I will try to provide as much as I can.

    Kind regards,

  • Jeffrey Veer 41 posts 308 karma points
    May 01, 2023 @ 15:03
    Jeffrey Veer
    0

    I just noticed that this question was raised recently in https://our.umbraco.com/packages/website-utilities/vendr/vendr-support/111141-discounts-with-price-type-of-base-price-not-working-as-excepted

    However, since applying the price adjustment on the base price is working completely fine up to the order finalization it would be nice if it would still be supported (or not work on anything before the finalization) to prevent accidents.

    Is there any other reason on why it is implemented this way? Otherwise we might choose to add a custom task and still apply the adjustments, if I'm not missing anything here.

  • Matt Brailsford 4124 posts 22220 karma points MVP 9x c-trib
    May 01, 2023 @ 16:23
    Matt Brailsford
    0

    I’ll have a look at adding some validation to ensure you only apply a base price adjustment to bundle order lines, but I’m not sure your reason for wanting to continue to use it.

    Without using bundles, adjusting the base price is no different to adjusting the unit price, so why wouldn’t you switch to adjusting the unit price that actually works in your scenario.

    Am I missing something?

  • Jeffrey Veer 41 posts 308 karma points
    May 02, 2023 @ 08:01
    Jeffrey Veer
    0

    Hi Matt,

    I agree that it's a bit of a strange setup, but it's because we need to change the price before other discounts (which we do on unit price).

    For example we want to apply a 20% discount on outlet products. On top of the new price an additional 15% member discount is applied, for a total of 32% discount.

    The 20% discount is configured on the product content node in Umbraco, not as a discount rule in Vendr.

    Normally we would change the base price with a ProductAdapter or ProductCalculator to directly work with the 20% discounted price. But we need to have the original price (before outlet discount) in the processing of orders to an external system.

    We now override the ApplyOrderPriceAdjustmentsTask with a custom implementation to set the BasePrice adjustments before calling the base implementation.

    This works for us, but I think it would be nice to consider supporting the adjustments on BasePrice by default.

    If you think we should implement this in a different way, I would love to hear it; but with the requirements of the client I'm afraid we need to implement it this way.

    Kind regards,

  • Matt Brailsford 4124 posts 22220 karma points MVP 9x c-trib
    May 02, 2023 @ 11:16
    Matt Brailsford
    0

    Ok, makes some sense but why not apply the 20% discount through the discounts system? These are applied in order so you can guarantee the sequence they are applied in.

  • Jeffrey Veer 41 posts 308 karma points
    May 02, 2023 @ 12:28
    Jeffrey Veer
    0

    The main reason to have the percentage configured on the products itself was for easier configuration by the content editor. That way they can manage the price and outlet discounts in one place.

    However we could still make a custom discount reward that would get the percentage from the product.

    A different reason, although that maybe wouldn't matter too much; is that we display the outlet and member discount in different ways on the shopping cart. So by giving one on the BasePrice and the other on the UnitPrice we are able to separate them easier, since we can use the properties from Vendr directly without calculating ourselves using the Adjustments.

    Although I said the previous solution worked for us, we just noticed that the adjustments are calculated every time the order is loaded in the backoffice. This will cause issues when the prices of the products will update. The reason for this is that we can't access the BasePrice.Adjustments on the OrderLineReadOnly.

    Added after 2 hours:

    This is most likely also the reason why the PriceAdjustments aren't persistent, because I also notice that on order recalculations, the PriceAdjustments in the database get a new id; most likely they are deleted and recreated? Might be because the OrderLineReadOnly doesn't have a BasePrice property, so it doesn't map the values?

    In theory we could retrieve it directly from the database, but I think we may look at using the UnitPrice instead to prevent making it too complex..

  • Matt Brailsford 4124 posts 22220 karma points MVP 9x c-trib
    May 03, 2023 @ 08:59
    Matt Brailsford
    100

    Ok, so I've pushed a new build to our unstable feed at https://nuget.outfield.digital/unstable/vendr/v3/index.json (version 3.0.12-beta0003) which no longer requires the orderline to be a bundle to have a base price.

    If you want to give this a try and see if it works, that would be great.

  • Jeffrey Veer 41 posts 308 karma points
    May 04, 2023 @ 11:59
    Jeffrey Veer
    0

    Hi Matt,

    That's awesome, thanks a lot!

    I had already changed the implementation to use the discount on UnitPrice, but I'll make sure to test the discount on BasePrice as well.

    As soon as I've tested it I will get back to you.

  • Jeffrey Veer 41 posts 308 karma points
    May 09, 2023 @ 15:14
    Jeffrey Veer
    0

    Hi Matt,

    I've tested this version by placing an order with a BasePrice adjustment, and the prices/adjustments are persisted after finalizing the order.

    Thank you very much for the update, as always!

    Since we've already completed the request by the client using the UnitPrice, it's no blocking issue for us at the moment; so from us there's no rush in releasing an stable update. :)

    Kind regards,

  • Matt Brailsford 4124 posts 22220 karma points MVP 9x c-trib
    May 09, 2023 @ 15:16
    Matt Brailsford
    1

    No worries. Thank you for testing the update resolved the issue. 🙏

Please Sign in or register to post replies

Write your reply to:

Draft