Add "onItemAdded" event to CartIcon element

It would be nice to have an “onItemAdded” event to the CartIcon element. That way I could listen to when the user just added an item to the cart.

What I am looking for with this event listener is to be able to detect when the user adds an item to the cart. Be it using the API or by clicking on the “Add to cart” button from the standard Product Page from the Wix Store.

Updated the post above to reflect the fact that the event should be triggered by the “Add to cart” button from the standard Product Page from the Wix Store too. In other words, any time an item gets added to the cart, be it by pressing a button or programmatically using the API, this event should get triggered.

The event should be “onCartChanged” not “onItemAdded”. We need to be aware if quantity changed or if an item is removed from the cart as well

That’s a good point! For my current use case I only need to listen to the “item added” event; but I can imagine many other use cases where an item being removed is also of interest.
Do you know if there is currently any work around this?

Hey @plomteuxquentin ,
I didn’t try it yet (will do that the next few days), but I believe we can achieve that with Web Modules since the wix-store-backend has some additional functionality. I will keep this thread updated if I achieve that.

Still, I would keep the request to have that feature on the frontend.

Yeah you’ll need https://www.wix.com/corvid/reference/wix-stores-backend.html#getCurrentCart

But the only way to know what’s the current cart status is to call the API over and over. which is a pretty hacky

Therefore this feature request is needed