Events

In order to listen to Snipcart events, you can use the on method:

Snipcart.events.on('{eventName}', callback);

Public events

item.adding

Before an item gets added to the cart, an item.adding event is triggered. The callback function receives the ParsedCartItem as an argument.

Snipcart.events.on('item.adding', (parsedCartItem) => {
    console.log(parsedCartItem);
});

item.added

After an item gets added to the cart, an item.added event is triggered. The callback function receives the ParsedCartItem as an argument.

Snipcart.events.on('item.added', (parsedCartItem) => {
    console.log(parsedCartItem);
});

cart.created

When a cart gets created (e.g., when an item gets added for the first time), a cart.created event is triggered. The callback function receives the CartResponse as an argument.

Snipcart.events.on('cart.created', (cartResponse) => {
    console.log(cartResponse);
});

cart.confirmed

When an order is placed and the cart gets confirmed successfully, a cart.confirmed event is triggered. The callback function receive the CartConfirmResponse as an argument.

Snipcart.events.on('cart.confirmed', (cartConfirmResponse) => {
    console.log(cartConfirmResponse);
});

Browser context events

summary.checkout_clicked

When a customer clicks on a show cart button, a summary.checkout_clicked event is triggered. In this case, the callback function takes no arguments.

Snipcart.events.on('summary.checkout_clicked', () => {
    // Anything goes...
});