modules/cart · npm: @86d-store/cart
Installation
Configuration
Initialize the Module by passing it to your module client. Both options have defaults, so you can omit them.number
default:"604800000"
Guest cart time-to-live in milliseconds. After this window elapses, the cart counts as expired. Defaults to 7 days (604,800,000 ms).
number
default:"100"
Maximum number of distinct line items a single cart may hold. Adding a new product beyond this limit returns an error. Updating the quantity of an existing item is not affected.
Store endpoints
All store endpoints return a consistent response shape:POST /cart/clear removes all items but preserves the cart entity itself. The cart ID and its Customer or Guest association remain intact.Admin endpoints
Components
Cart
TheCart component renders a slide-in drawer from the right side of the screen. It displays the current cart items, the subtotal, and a link to proceed to Checkout. The component fetches its own data and takes no props.
Cart in your main layout so it is available on every page:
CartButton
CartButton opens the cart drawer when clicked and shows a badge with the current item count when the cart has items.
CartDrawerInner
The inner content area of the cart drawer. Use this when you want to embed the cart contents directly on a page rather than inside a slide-out panel.CartFloatingPill
A compact floating pill at the bottom of the viewport. It shows the item count and opens the cart drawer on click, which makes it a good fit for mobile-first layouts in place ofCartButton.
Types
Current behavior and limits
Guest vs. authenticated carts. Guest carts are identified by aguestId UUID. When a Customer signs in, their guest cart can coexist alongside their authenticated cart; both carts reference different IDs. If you want them merged, your Checkout flow has to do it.
Deterministic item IDs. Cart item IDs follow the pattern ${cartId}_${productId}[_${variantId}]. This means adding the same product (or product plus variant) twice merges the quantity into the existing line item rather than creating a duplicate. Different variants of the same product are always treated as separate line items.
Swappable storage. The Module ships with an in-memory adapter by default. To use a different persistence layer, replace the adapter in your module configuration.
Related pages
- Checkout for the purchase path that consumes a Cart
- Products
- Inventory
- How commerce records relate
- 86d glossary
- Versioning and maturity