...
The przGreenbackAddToCartEvent
event fires when adding to the cart is triggered in the Greenback widget. The event will contain products in an array of objects and each has an ID IDs and quantity.
Syntax
Use the code below to listen to the event when it fires.
...
Name | Data Type | Example | Explain | |||||
---|---|---|---|---|---|---|---|---|
detail | array |
| The detail contains a list of products added to the cart.
|
...
Inspect the page
Go to the page that has the Greenback widget on. Right-click on the page and click oninspect
. It opens up the devtool panel. Then click on theconsole
tab within the dev tool panel.Add event listener
Within the console panel copy and paste the sample code below.Code Block language js document.addEventListener('przGreenbackAddToCartEvent', function(event) { const items = event.detail; console.log('Items added to cart:', items); })
Press enter
Add product to cart
Navigate to the Greenback widget and interact with the chat to add a product to the cart while keeping the console open. Once the add-to-cart is triggered you should see a message in the console showing all items passed in the event.