Skip to main content

Function: mergeAnonymousCart()

mergeAnonymousCart(cfg): Promise<Cart | null>

Defined in: composables/shared/utils/mergeAnonymousCart.ts:48

Copies every item from an anonymous cart into a target authenticated cart.

Parameters

cfg

MergeAnonymousCartConfig

The merge configuration.

Returns

Promise<Cart | null>

The latest cart returned by the final successful add, or null when the anonymous cart is empty, missing, or is itself the target.

Remarks

Uses the Services.cart SDK service: each item is copied via a serial cart.addItemToCart call (serial because every call returns the full cart, so parallel calls would race). Child items and notes are forwarded when present; individual failures are caught and logged without aborting the loop.