I’m working on a discount system where customers get a 10% price reduction when they use specific promotional codes during checkout. The problem I’m facing is that when I test this setup, the webhook fires immediately after the order gets created, but it doesn’t include the promotional code details yet.
It seems like there’s a timing mismatch where the webhook gets sent before all the order information is fully processed. Has anyone found a solution to make webhooks wait until all order data is complete? I need the promotional code information to be available when the webhook payload arrives.
Use the order/updated webhook instead - it fires whenever order data changes, so you’ll catch promo codes after Shopify finishes processing. Worked way better than order/created for me with the same timing issues.
had the same issue a while ago. switching to the order/paid webhook helped me since it triggers after payment is processed, so all promo details are included. give it a shot, might work for you too!
Had this exact issue last year. Instead of making Shopify wait, I built a retry mechanism. When my webhook gets an order, I check if the discount_codes array is empty or missing the promo data I need. If it’s not there, I return a 422 status - this tells Shopify to retry later. Shopify automatically retries failed webhooks up to 19 times with longer delays each time, so the order processing gets enough time to finish. Works way better than polling the API or adding delays since Shopify handles all the retry logic for you.
Yeah, this is super common with Shopify webhooks. I gave up trying to make Shopify wait and just built in a delay on my side instead. I queue the order data first, then wait 2-3 seconds before processing it. During that wait, I hit Shopify’s API to grab the full order details with discount codes. Not pretty, but it works reliably for these race conditions. You could also switch to GraphQL webhooks - they usually have more complete data than REST ones, but you’d have to rebuild your current setup.
Had this exact issue building a loyalty program integration. Here’s what worked: I set up a polling fallback alongside the webhook. The webhook handler checks if all the required data’s there. Missing promo code details? I save the order ID and run a background job that hits the Orders API every 30 seconds for up to 5 minutes until the complete data shows up. This catches orders where webhook timing’s off without breaking the normal flow. Polling overhead’s minimal since most orders work fine the first time, and you get reliable promo code data when you need it.