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 line item.
cartDetailsRecord<string, CartEntry>Canonical line item map keyed by product id.
formattedTotalPricestringLocalized currency string you can drop straight into UI.
lastClicked{ id: string; label: string } | nullMetadata describing the last button interaction, useful for animations.
shouldDisplayCartbooleanTrue when the customer has interacted with the cart UI recently.
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!