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
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>.Related
CartDevtools CartFormProps CartProviderProps AppCartConfig BaseCartActions BuyerIdentityActions CartActions CartAttributeActions