umbraco / Umbraco.Commerce.DemoStore

MIT License
12 stars 13 forks source link

How to create a new event targeting properties in Umbraco #10

Open JamiePattison opened 6 months ago

JamiePattison commented 6 months ago

I have added a new property to my Item/Product Document Type which contains other Commerce properties such as SKU.

I need to validate the value it contains before adding the product to the cart.

  1. I noticed there is an event for this (ValidateOrderProductAdd) which had been demoed to check the stock value but should I be adding a new Event for my needs? If yes how do I go about this?

  2. If I can use the existing validation, that's fine but again how do I access the newly created property as I can't see it listed under evt?

Or simply put should I do this in the controller when adding the product?

mattbrailsford commented 6 months ago

Hi Jamie, there is a guide here for adding your own validation handlers https://docs.umbraco.com/umbraco-commerce/how-to-guides/limit-orderline-quantity

To access the property, you'd probably need to use the product reference of the order line to lookup the product node.