CartMutation

cart · /core·type

Discriminated union of every operation the kernel can route to an adapter. Pass to ; the kernel dispatches on kind to the corresponding adapter method, guarded by .

Definition

@nordcom/commerce-cart
type CartMutation = { attributes: KV[]; kind: 'add-line'; quantity: number; snapshot: ProductSnapshot; variantId: string } | { kind: 'update-line'; lineId: string; quantity: number } | { kind: 'remove-line'; lineId: string } | { kind: 'clear' } | { code: string; kind: 'apply-discount' } | { code: string; kind: 'remove-discount' } | { code: string; kind: 'apply-gift-card' } | { id: string; kind: 'remove-gift-card' } | { kind: 'update-note'; note: string } | { attributes: KV[]; kind: 'update-attributes' } | { kind: 'update-buyer-identity' } | { kind: 'custom'; name: string; payload: unknown };

{ attributes: KV[]; kind: 'add-line'; quantity: number; snapshot: ProductSnapshot; variantId: string } | { kind: 'update-line'; lineId: string; quantity: number } | { kind: 'remove-line'; lineId: string } | { kind: 'clear' } | { code: string; kind: 'apply-discount' } | { code: string; kind: 'remove-discount' } | { code: string; kind: 'apply-gift-card' } | { id: string; kind: 'remove-gift-card' } | { kind: 'update-note'; note: string } | { attributes: KV[]; kind: 'update-attributes' } | { kind: 'update-buyer-identity' } | { kind: 'custom'; name: string; payload: unknown }

Example

const mutation: CartMutation = { kind: 'add-line', variantId: 'v_1', quantity: 2 };
await kernel.mutate(ctx, mutation);

RunCartAdapterContractOpts runCartAdapterContract CartCapabilityUnsupportedError CartError CartNotFoundError CartProviderError CartUserError CartAdapter

Sourcetypes.ts:193Edit the JSDoc directly

On this page