use-shopping-cart logouse-shopping-cart

Cart properties overview

Reference table for the derived properties returned by use-shopping-cart.

All of these values are exposed by useShoppingCart() so you can render totals, badges, or debug panels without reaching into internal state. The linked pages go deeper on each property.

PropertyTypePurpose
cartCountnumberTotal quantity across every cart entry.
cartDetailsRecord<string, CartEntry>Canonical cart entry map keyed by product id.
formattedTotalPricestringLocalized currency string you can drop straight into UI.
lastClickedstringThe ID saved by storeLastClicked(), or ''.
shouldDisplayCartbooleanWhether your cart UI should be open; set by the cart display helpers.
totalPricenumberRaw integer total (in the smallest currency unit) for calculations.

ℹ️ Looking for optimistic state or helper functions? See the useOptimisticCart hook and the actions section for mutation helpers.

Shopping Cart

Your cart is empty

Try the interactive demos on the docs pages!