No discount when purchasing certain products (Giftcards)
Hi,
The shop we are creating are, amongst a lot of physical stuff, selling gift cards. Under no circomstance can there be added a discount to gift card order lines. And to the total amounts for that sake if it means discounting the gift card.
You cannot get 10% off when buying a gift card for example.
Is there a pipeline or event or whatever that I can use to do this? Or do I have to make a custom discount rule that prevents this? A discount rule would mean that the editor needs to remember to put this on all campaigns in the correct way, and you know you cannot trust an editor :)
So you could probably do it as a 2 pronged attack using validation event handlers for both ValidateOrderProductAdd and ValidateOrderDiscountCodeRedeem preventing on from being added if the other is present, or you could also do it in a single ValidateOrderSave event handler checking to see if there are any discounts + gift card order lines.
No discount when purchasing certain products (Giftcards)
Hi,
The shop we are creating are, amongst a lot of physical stuff, selling gift cards. Under no circomstance can there be added a discount to gift card order lines. And to the total amounts for that sake if it means discounting the gift card. You cannot get 10% off when buying a gift card for example.
Is there a pipeline or event or whatever that I can use to do this? Or do I have to make a custom discount rule that prevents this? A discount rule would mean that the editor needs to remember to put this on all campaigns in the correct way, and you know you cannot trust an editor :)
Thanks /Rune
Hey Rune,
So you could probably do it as a 2 pronged attack using validation event handlers for both
ValidateOrderProductAdd
andValidateOrderDiscountCodeRedeem
preventing on from being added if the other is present, or you could also do it in a singleValidateOrderSave
event handler checking to see if there are any discounts + gift card order lines.See docs here for some more info on validation event handlers https://vendr.net/docs/core/2.1.0/umbraco-v9/key-concepts/events/#validation-events
Hope this helps
Matt
Ah ok. So you would simple block the saving of the order if the user is trying to do both discount and gift card. That could work yes.
I will try it and get back to you with the result so others might learn something.
/Rune
Yea, I think this would be the simplest option without needing to create your own custom discount rule. 👍
Matt
EDIT: There was a small bug in the script. Which have been fixed
It worked like a charm. There's some error handling (everywhere) in the UI but that's what you can expect.
Here's my code:
Fantastic! 🎉
Yea, error handling is a must, but if it's all via validation exceptions hopefully you only need to implement that once.
is working on a reply...