Skip to content
English

Usage

import { ShopCart } from './ShopCart.jsx'

// Without callbacks the cart runs on its sample bag. Wire it to your shop:
<ShopCart
  locale="en"
  currency="USD"
  items={bag.lines}            // [{ id, name, variant, price, qty, image }]
  freeFrom={80}
  delivery={5}
  loading={bag.loading}
  error={bag.error}
  onRetry={bag.reload}
  onQuantityChange={(id, qty) => bag.setQuantity(id, qty)}
  onRemove={(id) => bag.remove(id)}
  onApplyCode={async (code) => (await checkCode(code)) ? 0.1 : false}
  onCheckout={async (lines, totals) => (await placeOrder(lines, totals)).number}
/>

Props

PropTypeDefaultWhat it does
locale'en' | 'zh-CN' | 'es' | 'ja''en'Language of the built-in text and sample bag.
itemsArray<{ id, name, variant, price, qty, image?, max? }>sample bagThe lines of the bag. A new array replaces the bag; quantities and removals then live in the block. `image` is the line’s picture; without it a plain parcel is drawn.
currencystringby localeISO currency code for every amount.
freeFromnumberby localeAmount after discount from which delivery is free; the meter fills towards it.
deliverynumberby localeDelivery cost below that amount.
loadingbooleanfalseShows the skeleton of the bag while it loads.
errorboolean | stringfalseShows the error banner with a retry button; a string replaces its sentence.
onQuantityChange(id, qty) => void—A quantity changed.
onRemove(id) => void—A line was removed. It can still be put back for six seconds.
onApplyCode(code) => Promise<number | false>—Checks a promo code: resolve with the discount rate (0.1 is 10 %) or false.
onCheckout(lines, totals) => Promise<string | void>—Places the order; resolve with the order number to show it.
onContinue / onBrowse / onRetry() => void—After an order, from an empty bag, and from the error banner.
labelsobject—Replaces any built-in text (keys as in copy.js).

Add it to your project

Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the block together with the components it is built from.

ShopCart.jsxshop-cart.csscopy.jskit.jsxkit.cssui/base-button/ui/empty-state/ui/rolling-number/ui/alert-banner/ui/success-check/ui/number-input/ui/text-input/ui/skeleton-shimmer/tokens.cssREADME.md

The block, its stylesheet and text, the shared kit, the components it uses and tokens.css install together into one folder.