Carts AI agents can manage: quantities, promo codes and totals
Usually fixed by: Developer · Typical effort: hours
The cart is where an AI agent checks its work. A person asks for "two bags of the decaf, and use my code SPRING10", and the agent has to change a quantity, apply a code and read back a total the person will agree to pay. If the cart makes any of that hard, the agent guesses or gives up. This guide covers what a cart needs so agents can manage it reliably.
Why the cart matters more for agents
A person glances at a cart and knows whether it looks right. An agent has to read it. Before it hands over for payment, a careful agent reports back: what's in the cart, how many, what it costs and when it arrives. It gets every one of those facts from your cart page. If the cart can't be read, the agent can't confirm, and the order stalls at the point where you've already done the hard work of winning it.
For the whole journey from search to payment, see how to make checkout work for AI shopping agents. This guide zooms in on the cart itself.
Quantity controls
The most common problem is a pair of "−" and "+" icons with no names, next to a number that's styled text rather than a field. A person sees a stepper. An agent sees two unnamed buttons and a number it can't change directly.
- Use a labelled number field. A real
<input type="number">whose label names the item lets an agent type the quantity it wants. - Name the stepper buttons. If you keep plus and minus buttons, give each a name: "Increase quantity of Ethiopia Yirgacheffe".
- Say limits in words. "Limit 4 per order", next to the field. An agent that asks for 6 and silently gets 4 will tell the person the wrong thing.
- Confirm every change. Update the line total and the cart total on the page, and announce it in a status message, so the agent knows the change took.
- Make "Update cart" a real button if your cart needs one, placed next to the quantities, not hidden at the bottom.
A cart line that does all of this:
<li>
<a href="/products/ethiopia-yirgacheffe?variant=340g">Ethiopia Yirgacheffe, 340 g</a>
<label for="qty-1">Quantity</label>
<input id="qty-1" name="qty-1" type="number" min="1" max="4" value="2">
<span>Limit 4 per order</span>
<span>$36.00</span>
<button type="button" aria-label="Remove Ethiopia Yirgacheffe, 340 g">
<svg aria-hidden="true">…</svg>
</button>
</li>
<p role="status">Quantity updated to 2. Subtotal $36.00.</p>
Remove buttons
- Name what each one removes. On a cart with three items, three buttons called "×", or nothing at all, leave the agent guessing which is which. "Remove Ethiopia Yirgacheffe, 340 g" leaves no doubt.
- Confirm in text. "Ethiopia Yirgacheffe removed. Undo." A line that simply vanishes could mean it was removed, or that the page is still loading.
- Don't make zero the only way out. Setting the quantity to 0 should work, but a clear remove button shouldn't be missing.
AgentScore's "Buttons and links have names" check looks for exactly this kind of icon-only control on your home page. Apply the same rule in the cart, where it matters more.
Promo code fields
People often ask an assistant to use a code they already have. That only works if the agent can find the field, apply the code and tell whether it worked.
- Give the field a visible label, such as "Discount code", not just placeholder text. Placeholders vanish as soon as typing starts, and many agents ignore them.
- Pair it with a real "Apply" button. Not a form that only submits when someone presses Enter.
- If it's collapsed behind "Have a code?", make that a real button that says it opens something (
aria-expanded), not a styled line of text. - Explain failures in words. "SPRING10 expired on March 31" or "This code doesn't apply to sale items" lets the agent tell the person why. "Invalid code" in red does not. See error messages AI agents can understand.
- Show the applied discount as its own line, with the code name, the amount and a named button to remove it.
Totals the agent can repeat back
The goal is simple: an agent should be able to say "The total is $44.18, including $5.00 shipping and $3.18 tax" and be right. That means each part of the total is on the page as text.
| Line | What to show |
|---|---|
| Subtotal | The sum of the items, as text, updated after every change |
| Discounts | Each code or promotion by name, with its amount |
| Shipping | The cost for the chosen method, or an estimate with the method named. If it truly depends on the address, say "Calculated at checkout" |
| Tax | The amount, or "Calculated at checkout". Say whether prices already include tax |
| Total | The final figure with its currency |
- Show the currency clearly. "$" alone is ambiguous on a site that sells in several countries. See international sites for AI agents.
- Put free-shipping thresholds in words: "Spend $12.00 more for free shipping." A progress bar alone tells an agent nothing.
- Keep prices as text in the page, not in images or drawn on a canvas. See prices AI agents can read.
Carts that survive the handoff
Most agents hand back to the person to sign in or pay, and that can happen hours later, or on another device. A cart that empties in the meantime undoes the agent's work.
- Keep carts for days, not minutes. Don't clear them on a short session timeout.
- Keep the cart at a stable URL, such as
/cart, as a full page as well as any slide-out drawer. - Consider cart links. Some platforms can rebuild a cart from a URL (Shopify calls these cart permalinks), which lets an agent hand the person a link that opens the same cart. Ask your platform what it supports.
- Explain changes. If stock or a price changes while the cart waits, say so on the page: "Only 1 left. We've changed your quantity to 1."
Upsell pop-ups and cart drawers
An upsell window after "Add to cart", or on the way to checkout, is one more thing an agent has to get past.
- If you use one, make it a proper dialog with a heading, a "No thanks" button with text, and a named close button. See cookie banners and pop-ups.
- Never pre-add extras, such as a pre-ticked protection plan. An agent may not notice, and the person pays for something they didn't ask for. In some markets, such as the EU, consumer law already restricts pre-ticked extras.
- Recommendations under the cart are fine. Keep the checkout button above them.
- Give a cart drawer a labelled close button and a real link to the full cart page.
What AgentScore checks on your cart
The free AgentScore scan is read-only: it loads pages but never adds anything to a cart. On many stores the cart is empty when it looks, and the scan says so rather than guessing. For stores, these checks cover the cart:
- AI agents can open your product, pricing and cart pages. It requests your cart as ChatGPT-User, Claude-User and Perplexity-User and compares what they get with what a browser gets.
- AI agents aren't blocked or shown a CAPTCHA at the cart and checkout.
- Cart and checkout fields are labelled for agents. Labels rather than placeholders, the right input types, and autocomplete. If the empty cart shows no fields, this is marked "not tested".
- Shoppers can check out without an account. It reads the cart for wording like "Sign in to check out" or "Check out as a guest".
- Key pages are linked from the home page, including the cart, with ordinary links in the HTML.
Changing quantities, applying codes and reading totals need items in the cart, so they belong to Task completion, which the free scan marks "not tested". To test them, set up a Ghost Agent test with a goal in your own words, such as "Add two bags of decaf, apply the code TEST10 and go to checkout", using a test code you've created, and a pass condition that looks for the code's name on the final page. Ghost Agents stop at the payment form, so no order is placed. See how to test your key journeys with AI agents.
A five-minute cart test. Add two items, then use only the keyboard to change a quantity, remove an item and apply a code. Then read the cart aloud as if over the phone: items, quantities, discount, shipping, tax, total. Anything you had to look at a picture to work out, an agent can't see.