Skip to main content

Function: initCart()

initCart(config): Promise<Cart>

Defined in: composables/shared/utils/cartInit.ts:68

Resolves the active cart for the current user. Returns an existing OPEN cart if one exists, otherwise creates and initialises a new cart with default addresses.

Parameters

config

CartInitConfig

The cart initialisation configuration.

Returns

Promise<Cart>

The resolved (existing or newly created) cart.

Remarks

Uses the Services.cart SDK service exclusively:

  • cart.getCarts searches for an existing OPEN cart by contact/customer/company.
  • cart.getCart hydrates the matched cart by cartId.
  • cart.startCart creates a new cart when no open cart is found.
  • cart.updateCartAddress assigns the user's default invoice and delivery addresses to the new cart (best-effort; failures are swallowed).