Item.adding event - how to prevent

I wish to make a call to my own API when a user clicks to add to cart - this is to check that the item has not been sold or that sufficient quantity remains. I would like to prevent the item being added if it is not available. I can see how one could have used ev.preventDefault in version 2 but this does not seem to exist in version 3. How can I do this please?

For example, if I just wanted to prevent it happening it would be nice to do something like this (but it doesn’t work):'item.adding', (parsedCartItem) => {       
return false;

Hi @sunnyjayjay,

Unfortunately, this is not possible at the moment in v3. That being said, you could listen to the item.added event. In the body of the callback do some validation and use the Javascript SDK to remove your item if necessary.

item.added documentation
Snipcart.api.cart.item.remove documentation