useCart

cart · /react·functionthrows CartProviderError

Composite hook stitching every slice into the shape historically returned by the storefront's monolithic useCart. Prefer the focused slice hooks for new consumers — calling all slices forces re-renders on every change.

Signature

@nordcom/commerce-cart
function useCart(): { cart: { attributes: { key: string; value: string }[]; buyerIdentity: BuyerIdentity; checkoutUrl: string; cost: CartCostValue; discountCodes: { applicable: boolean; code: string }[]; giftCards: { amountLeft: Money; id: string; lastCharacters: string }[]; id: string; lines: CartLine<unknown>[]; note: string; totalQuantity: number }; cartReady: boolean; error: string; status: CartStatus; addLine: unknown; clear: unknown; removeLine: unknown; updateLine: unknown };

Returns

An object with cart (when seeded), status fields, and the capability-typed action methods.

Throws

CartProviderError
when called outside <CartProvider>.

CartDevtools CartFormProps CartProviderProps AppCartConfig BaseCartActions BuyerIdentityActions CartActions CartAttributeActions

Metadata@nordcom/commerce-cart@0.2.2Open in GitHub ↗

On this page