Hi Shopify Developer Community,
I’m a developer working on a custom integration for our store, and I’m running into a frustrating issue with automatic discounts not applying right away to products created dynamically via the GraphQL Admin API. This is causing checkout delays that are leading to cart abandonment and lost sales—especially since we’re investing heavily in marketing to drive traffic. I’ve already escalated this through multiple support chats (tickets: 61704009, 61704612, 61705284), but the responses pointed to expected “indexing delays” (up to 2 minutes even for single products) and suggested workarounds like switching to manual discount codes or adding artificial delays in our workflow. These aren’t viable for our real-time customization flow, as they break the user experience.
I’d love insights from fellow developers or Shopify engineers on a proper fix—perhaps something around forcing immediate indexing, API hooks, or alternative discount application methods that don’t rely on post-creation syncing.
Issue Description
- What happens: We use the GraphQL Admin API (
productCreatemutation) to generate a single, customized product variant on-the-fly (e.g., based on user inputs like engraving). The product adds to the cart successfully via the Storefront API. However, at checkout:- The automatic discount (set up in the admin under Discounts > Automatic discounts) doesn’t apply initially.
- It takes 2-3 page refreshes or about 2 minutes for the discount to “kick in” and reflect the correct pricing.
- Impact: Customers see inflated prices at first, leading to confusion and drop-offs. This is killing conversions on our personalized product pages.
Steps to Reproduce
-
Create a product via GraphQL Admin API (example mutation below—sanitized for our store):
mutation productCreate($input: ProductInput!) { productCreate(input: $input) { product { id title variants(first: 10) { edges { node { id price } } } } userErrors { field message } } } # Variables example { "input": { "title": "Custom Engraved Ring - User Order", "productType": "Personalized Jewelry", "vendor": "ABCD", "variants": [ { "price": "299.00", "sku": "CUSTOM-{{order_id}}" } ], "status": "ACTIVE" } } -
Add the new product to cart using Storefront API (
cartLinesAdd). -
Proceed to checkout (/checkouts/{token}).
-
Observe: Subtotal shows full price—no discount applied. Refresh 2-3 times → discount applies.
What We’ve Tried
- Support Recommendations:
- Add a 2-minute delay in our app workflow before redirecting to checkout (not feasible for UX).
- Trigger re-indexing by making a minor edit (e.g., add/remove space in title) post-creation—adds complexity and still inconsistent.
- Switch to manual discount codes with auto-apply: This works instantly but requires generating/applying unique codes per session, which complicates our flow and doesn’t match our “always-on” 20% off personalized items discount.
- Our Tests:
- Confirmed the discount targets the correct product type (“Personalized Jewelry”) and has no exclusions.
- Tested with single products only—no bulk ops.
- Verified API responses: Product is created with
status: ACTIVE, but eligibility checks at checkout seem delayed. - Screenshot of discount settings: [Attached: discount-settings.png] (20% off on specific product types, active, no min/max purchase reqs).
- No errors in API responses or browser console.
Questions for the Community
- Is there a way to force immediate indexing after
productCreate? Maybe a separate mutation or webhook to notify the discount engine? - Can automatic discounts be applied client-side via Storefront API extensions, bypassing indexing?
- Any known workarounds using Draft Orders or other APIs that apply discounts synchronously?
- Has Shopify’s dev team addressed similar indexing delays for real-time product creation? (Support mentioned a feature request was logged, but no ETA.)
We’re on the latest GraphQL API version (2024-10) and using a custom app with necessary scopes (write_products, read_discounts, etc.). Happy to share more code snippets, API logs, or hop on a quick call if needed.
Thanks in advance for any guidance, this one’s a real blocker, and your expertise would mean a ton for keeping our customers happy!
Best,
Ayush Varma
Shopify Developer,