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.
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?
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?
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.
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
You mean an event that gets fired when a price adjuster is applied? What's the use case?
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
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 anValidateOrderSave
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
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
Hi Johannes,
When you create a custom
PriceAdjuster
this will return a customPriceAdjustment
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 customPriceAdjustment
that has a customMyAdjustmentRef
property.Matt
I will give it a try! Thank you so much Matt!
//Johannes
is working on a reply...