Copied to clipboard

Flag this post as spam?

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


  • Johannes Lantz 98 posts 502 karma points
    Sep 29, 2021 @ 08:10
    Johannes Lantz
    0

    Event for Price adjuster

    Hi!

    I was wondering if there is an event for adding a price adjuster? I found one for discount, but I am assuming that dose not include price adjusters.

    //Johannes

  • Matt Brailsford 3290 posts 17430 karma points MVP 8x c-trib
    Sep 29, 2021 @ 08:31
    Matt Brailsford
    0

    You mean an event that gets fired when a price adjuster is applied? What's the use case?

  • Johannes Lantz 98 posts 502 karma points
    Sep 29, 2021 @ 08:44
    Johannes Lantz
    0

    Yes exactly!

    We have a API call in the price adjuster. In case that API fails for some reason, we would then like to stop the customer from continuing with the purchase. So I am thinking an event could be the way to go here.

    //Johannes

  • Matt Brailsford 3290 posts 17430 karma points MVP 8x c-trib
    Sep 29, 2021 @ 10:12
    Matt Brailsford
    0

    Hmmm,

    The best option I could think of is to store something in your custom PriceAdjustment that maybe signifies if the API was successful and then write an ValidateOrderSave validation event handler to check for the presence of a PriceAdjustment of your type, with that particular field set. If it is, then prevent the order from being saved?

    Matt

  • Johannes Lantz 98 posts 502 karma points
    Sep 29, 2021 @ 21:39
    Johannes Lantz
    0

    That could work! I am a bit unsure how I would go about doing it though.. My first thought was to set a custom property to the order depending on the API status. But I don't think that's the way to go about this. Or maybe it is?

    What do you think?

    //Johannes

  • Matt Brailsford 3290 posts 17430 karma points MVP 8x c-trib
    Sep 30, 2021 @ 08:02
    Matt Brailsford
    100

    Hi Johannes,

    When you create a custom PriceAdjuster this will return a custom PriceAdjustment type. On that type you can have whatever properties you like so one of those could be whether the API was successful. You can then lookup price adjustments of that type on the order when you run your validation rule and see if that property is set.

    If you checkout the docs here https://vendr.net/docs/core/1.8.0/key-concepts/price-amount-adjustments/#creating-custom-adjustments there is an example of a custom PriceAdjuster that returns a custom PriceAdjustment that has a custom MyAdjustmentRef property.

    Matt

  • Johannes Lantz 98 posts 502 karma points
    Sep 30, 2021 @ 17:06
    Johannes Lantz
    0

    I will give it a try! Thank you so much Matt!

    //Johannes

Please Sign in or register to post replies

Write your reply to:

Draft