Cart SystemReference
Events
cart:updated
When: The cart state changes — an item was added, removed, or quantities changed.
Payload:
| Field | Type | Description |
|---|---|---|
items | array | Current cart items after the update |
totals | object | Recalculated cart totals |
cart:item-added
When: A package is added to the cart.
Payload:
| Field | Type | Description |
|---|---|---|
packageId | number | ID of the package that was added |
quantity | number | Quantity added |
cart:item-removed
When: A package is removed from the cart.
Payload:
| Field | Type | Description |
|---|---|---|
packageId | number | ID 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);
});
});