Skip to content

UseCart

add: (sku, quantity?) => Promise<void>

string

number

Promise<void>


announcement: { n: number; } | null

Changes (n goes up) each time something was added, for a polite live region to speak once.

CartSnapshot.announcement


cart: Cart | null

The server’s cart, as of the last answer. Never carries the cart token.

CartSnapshot.cart


clear: () => void

Removes the cart and the pending order from this device. Call it from your own “forget this device” button if you do not hand the provider a visitors instance.

void


closeDrawer: () => void

void


count: number

Units in the cart. Moves optimistically with an add and is put back if the server refuses.

CartSnapshot.count


drawerOpen: boolean

CartSnapshot.drawerOpen


fault: CartFault | null

CartSnapshot.fault


hasHeader: boolean

A header cart button is mounted and speaks additions itself.

CartSnapshot.hasHeader


openDrawer: () => void

void


paying: boolean

A checkout has started and the shopper is on their way to the payment page. Guards a second submit.

CartSnapshot.paying


pending: boolean

A write is in flight.

CartSnapshot.pending


remove: (sku) => Promise<void>

string

Promise<void>


setQuantity: (sku, quantity) => Promise<void>

string

number

Promise<void>


status: CartStatus

CartSnapshot.status


store: CartStore | null

The store, for the actions the hook does not wrap. null when the cart is off or not ready.


testOrder: boolean

The checkout that started said it is a test-mode order.

CartSnapshot.testOrder