AddThisFeature

Shopping Cart

A cart that holds its contents, prices them correctly, and survives leaving the site.

involved Monetization

What it adds

A persistent cart holding line items with quantities, priced at load time and carried across sessions and sign-in.

What your agent is told to do

5
  1. 1

    Give a signed-out visitor a cart tied to a long-lived browser token, and give a signed-in user a cart stored against their account. On sign-in, merge the two by product and variant so a line the visitor already had gains quantity rather than appearing twice.

  2. 2

    Price the cart from the catalogue every time it is displayed, not from the numbers captured when the item was added. Store the quantity and the product reference on the line; treat price, tax, and availability as derived.

  3. 3

    Show the cart contents and total in a place the user can reach from every page, and make the totals break down into subtotal, discounts, shipping, and tax rather than a single opaque number.

  4. 4

    If the app already has Coupon and Promotion Codes, Tax and VAT Collection, or a hosted checkout, the cart must feed those rather than recomputing discounts and tax on its own. Extend the existing pricing path; do not add a second one.

  5. 5

    Do not treat the cart as an order. Nothing in the cart reserves inventory, and the authoritative price and stock check happens again at checkout, because a cart can sit untouched for weeks.

Edge cases it handles

8
  • A visitor who fills a cart and then signs in must end up with one cart containing everything. Merging by product and variant, and summing quantities against the per-order cap, prevents the same item appearing on two lines.
  • Prices change while a cart sits idle. Reprice on load, and if a line has gone up or down since it was last seen, say so plainly next to that line rather than silently charging the new amount.
  • An item can go out of stock or be delisted while in the cart. Keep the line visible but mark it unavailable, exclude it from the total, and block checkout until the user removes it or reduces the quantity.
  • Quantity must be capped against both available inventory and any per-order limit. Clamp the value server-side and tell the user why it was reduced; a client-only limit is trivially bypassed.
  • Totals must stay correct across currency, rounding, and discounts that apply to more than one line. Compute in minor units, apply multi-line discounts before rounding the total, and never let the sum of the displayed lines disagree with the charged amount.
  • Two tabs open on the same cart must not overwrite each other. Apply quantity changes as operations against the stored cart rather than saving a whole client-side snapshot.
  • Removing a line should be undoable for a short window. People remove the wrong row and re-adding it from scratch loses the configured options.
  • An abandoned cart still holds a browser token. Decide how long guest carts are retained and delete them on schedule rather than accumulating them forever.

Definition of done

8
  • The cart survives a page reload, a closed browser, and a sign-in without losing or duplicating lines.
  • Prices, discounts, and tax are recalculated on every render from the current catalogue.
  • Unavailable or delisted items are visibly flagged and excluded from the total, and block checkout.
  • Quantity limits are enforced server-side against inventory and per-order caps.
  • The displayed total matches the amount the payment step charges, to the minor unit.
  • Discounts and tax come from the app's existing promotion and tax logic, not a parallel implementation.
  • The feature matches the existing design system.
  • No existing functionality is broken.

Related features

How it works

  1. 1

    Copy the link

    Grab the Markdown instruction URL for this feature.

  2. 2

    Give it to your AI

    Paste it into Claude Code, Cursor, v0, Lovable — whatever you build with.

  3. 3

    It inspects, then implements

    Your agent reads your existing app first, then adds the feature to fit it.

Works with your stack

These instructions are written to adapt. They tell the agent to detect your framework, match your existing design system, and reuse what you already have — rather than assuming a particular stack.

Need it tighter than that? Customize the feature and tell it exactly what you're running.