Skip to main content

Function: useCart()

useCart(options): UseCartReturn

Defined in: composables/react/useCart.ts:128

useCart — cart resolution and line-item management.

Parameters

options

UseCartOptions

see UseCartOptions.

Returns

UseCartReturn

cart state plus async actions — see UseCartReturn.

Remarks

GraphQL integration: all backend calls go through services.cart (CartService) and services.crossupsell (CrossupsellService), derived from options.graphqlClient via createServices. resolveCart() runs the shared initCart flow (getCartsstartCartupdateCartAddress). addItem calls addItemToCart; updateItemQuantity / updateItemNotes call updateCartItem (the notes update is debounced); deleteItem calls deleteCartItem; addActionCode / removeActionCode call addActionCodeToCart / removeActionCodeFromCart; requestAuthorization calls requestPurchaseAuthorization; processCart calls processCart to convert the cart to an order; getCrossupsells calls crossupsell.getCrossupsells. Cart mutations require a cart id; addItem can create one on demand via createCart.