Next Commerce
Cart SystemReference

Events

cart:updated

When: The cart state changes — an item was added, removed, or quantities changed.

Payload:

FieldTypeDescription
itemsarrayCurrent cart items after the update
totalsobjectRecalculated cart totals

cart:item-added

When: A package is added to the cart.

Payload:

FieldTypeDescription
packageIdnumberID of the package that was added
quantitynumberQuantity added

cart:item-removed

When: A package is removed from the cart.

Payload:

FieldTypeDescription
packageIdnumberID of the package that was removed

Listening to Events

window.nextReady.push(() => {
  window.next.on('cart:updated', (data) => {
    console.log('Cart updated:', data);
  });

  window.next.on('cart:item-added', (data) => {
    console.log('Item added:', data);
  });

  window.next.on('cart:item-removed', (data) => {
    console.log('Item removed:', data);
  });
});

On this page