Ajax Cart API applies a customer-segment discount code to guest carts

Short description of issue

A customer-segment discount code shows as applied in guest carts. Checkout removes it only after the buyer enters an email.

Reproduction steps

Reproduced 2026-10-11 14:59 UTC.

  1. Open a new browser session. Do not log in.
  2. Send POST /cart/add.js with one full-price item from the code’s collection.
  3. Send POST /cart/update.js with {"discount": "MEMBER40"}. The response (trimmed):
"discount_codes": [{ "code": "MEMBER40", "applicable": true }],
"original_total_price": 6500,
"total_discount": 2600,
"total_price": 3900
  1. Go to checkout. The code stays applied until you enter an email. For an email outside the segment, checkout shows “MEMBER40 discount code isn’t available to you right now”.

Setup: a native code discount (DiscountCodeBasic). Its context is DiscountCustomerSegments with one segment (customer_tags CONTAINS '<tag>') and no other limits.

Additional info

Why this is a problem

Checkout blocks the order, so we lose nothing online. Two costs remain:

  1. Brand value. Restricted codes leak to coupon sites and group chats. Anyone with a leaked code sees the member price and the full saving in the cart. That alone devalues the code and the brand, even when the order never goes through.
  2. Physical retail. Buyers show the cart to our store staff and say the code works online, so the checkout failure must be a glitch. Staff then argue with a customer who holds a screenshot. Every merchant that also sells through Shopify POS has this problem.

A restricted code should not look applied before Shopify knows who the buyer is. “Not eligible until the buyer is identified” is the safer default.

Questions

  1. Is this behaviour intended? I could not find it in the Ajax API or discount docs.
  2. Can a storefront tell that eligibility still waits on buyer identity? A flag on discount_codes is enough.
  3. Is a setting planned to keep a segment code not applicable until the buyer is identified?

Both of our workarounds copy the segment rule into a second place. One checks customer.tags in the theme against a list of gated codes. The other rebuilds each segment code as an app discount, with a Discount Function that checks buyerIdentity.customer.

I can DM the shop domain. Thanks.

What type of topic is this

Feature request

Hi @Steve_Jiang, I had a look for you and can confirm this is expected today. Customer eligibility for a code is evaluated in checkout once the buyer is identifiable, from a logged-in profile or an email or phone entered at checkout. Until then the code can show as applied with discounted totals, then checkout keeps or removes it. The discounts docs cover how segment customers are identified at checkout.

There’s no storefront signal for pending eligibility. applicable reflects whether the code applies to the cart’s current contents, not buyer eligibility. The Storefront API’s CartDiscountCode exposes only code and applicable, so nothing flags that identity is still unresolved.

This is on the discount team’s radar internally, but right now I can’t confirm an ETA or whether a change to this behavior is on the way. I’ve passed your feedback along, so thanks for raising this here!