CartEvent

cart · /core·type

Discriminated union of every lifecycle event the cart kernel can emit. Consumers subscribe via and switch on event.type to handle the specific variant they care about.

Definition

@nordcom/commerce-cart
type CartEvent = { cart: Cart; type: 'cart.created' } | { cart: Cart; mutation: CartMutation; source: 'self' | 'broadcast'; type: 'cart.updated' } | { error: Error; mutation: CartMutation; source: 'self'; type: 'cart.mutation.failed' } | { cart: Cart; line: CartLine; type: 'cart.line.added' } | { cart: Cart; lineId: string; type: 'cart.line.removed' } | { type: 'cart.cleared' };

{ cart: Cart; type: 'cart.created' } | { cart: Cart; mutation: CartMutation; source: 'self' | 'broadcast'; type: 'cart.updated' } | { error: Error; mutation: CartMutation; source: 'self'; type: 'cart.mutation.failed' } | { cart: Cart; line: CartLine; type: 'cart.line.added' } | { cart: Cart; lineId: string; type: 'cart.line.removed' } | { type: 'cart.cleared' }

Example

bus.on('cart.updated', (event: CartEvent & { type: 'cart.updated' }) => {
  analytics.track('cart_updated', { cartId: event.cart.id });
});

RunCartAdapterContractOpts runCartAdapterContract CartCapabilityUnsupportedError CartError CartNotFoundError CartProviderError CartUserError CartAdapter

Sourceevents.ts:15Edit the JSDoc directly

On this page