useCartStore
useCartStore: UseBoundStore<Write<Write<StoreApi<CartStore>, StorePersist<CartStore, CartStore>>, StoreSubscribeWithSelector<CartStore>>>Source: cart.state.ts:130
The cart store. Call useCartStore.getState() to read the current CartState (items, totals, discounts, shipping), or subscribe to react to changes. To mutate the cart, use the sdk.cart.* operations (add, remove, update quantity, apply coupon…) rather than writing to the store directly.
Type
UseBoundStore<Write<Write<StoreApi<CartStore>, StorePersist<CartStore, CartStore>>, StoreSubscribeWithSelector<CartStore>>>
Default: cartStoreInstance
Example
CODE
const { total, items } = useCartStore.getState();
useCartStore.subscribe(cart => render(cart.total));