A developer built a Shopify checkout app extension designed to allow only one coupon code at a time—applying a new coupon should automatically remove the previous one. Despite this logic, one user managed to apply two coupons simultaneously on a single order, while other orders behaved normally. The developer has spent three days attempting to reproduce the issue in a dev environment without success, even testing slow network conditions and multiple browser tabs.
Suggested debugging approaches:
Implement explicit discount removal loops before applying new codes to prevent race conditions
Add logging/tracking within the extension to monitor discount application events
Use Shopify webhooks (CHECKOUTS_UPDATE) for backend anomaly detection
Review discount combination settings in Shopify admin, as certain configurations may permit stacking
Examine useEffect dependencies for potential race conditions in the code
Current status: The issue remains unreproducible. The developer needs to confirm the root cause before proposing a fix to the client. Screenshots show the checkout UI and admin order details confirming the double-coupon application. One responder recommended posting on Shopify’s developer community forum for more specialized assistance.
Summarized with AI on October 29.
AI used: claude-sonnet-4-5-20250929.
My app only allows user to apply only 1 coupon, if user apply another coupon,
the previous coupon will be deleted. All API I am using is from Shopify, but I don’t know how, in some special way,
only 1 user can apply 2 coupons in this screen and he has 2 orders with the same coupon, the other order can’t apply 2 coupons, I created the same 2 coupons on DEV environment to test but I can’t reproduce that case.
Does anyone know or have seen this case before? Or is there a solution to debug, I spent 3 days but couldn’t reproduce and test the code but still don’t know how
This sounds like a rare but possible edge case—likely caused by a race condition, stale session data, or Shopify’s discount logic being bypassed before your app fully loads.
To ensure only one discount is ever active, here’s solution:
Clear all existing discounts before applying a new one in your Checkout UI extension:
for (const code of checkout.discountCodes) {
await removeDiscountCode(code.code);
}
await applyDiscountCode(newCode);
Add logging/tracking in your extension to monitor when and how discount codes are applied or removed.
Use Shopify webhooks (CHECKOUTS_UPDATE) to track anomalies on the backend in real time.
Verify discount combination rules in the admin dashboard—some setups or customer segments might allow stacking.
Force synchronous control with await to avoid race conditions when removing/applying codes.
If you want me to help debug or review your code directly, please feel free to reach out—happy to help!
Thanks guys for read my issue, more clear about my case, I’m allow to apply 1 coupon code only, when I click button Apply, the previous coupon will be remove and new coupon will be apply. The first thing I need is reproduce that case to report with my client, because if I fix that issue with no report or not sure about that bug, i’m not sure that is solution
I tested by changing the network mode to very slow network, but in the checkout screen, after you click on the apply button, the button becomes loading state and you can’t do anything, can’t checkout, I tried with the case of opening 2 tabs on the browser but still can’t find the reason.
I saw the order details in the admin and got 2 coupons that were applied in the checkout, that means user action in the checkout, no other tools involved in calling the api
Check your useEffect cases @nhtbao101 we had something similar and had to handle it properly to prevent any race conditions.
Can’t really help much here without looking at your exact code. Also try posting on dev community forum instead as you’ll get better quality responses there instead.