A developer is building a custom rewards program and needs to display points earned in order confirmation emails for guest checkouts. The system calculates points server-side via webhooks (checkouts/start and checkouts/update) to account for promotions and bonuses.
Core Challenge:
For logged-in customers, storing data in customer metafields works fine
For guest checkouts, attempting to add metafields to orders fails with “ERR_NON_2XX_3XX_RESPONSE” because orders don’t exist yet during checkout
Order confirmation emails send immediately on order/create, leaving no time to inject calculated data
Suggested Approaches:
Use cart attributes (called “custom attributes” in the API) to pass data from frontend through checkout to the order
Generate estimated points on the frontend, then update with accurate data post-purchase
Use the ScriptTag API for more direct frontend JavaScript interaction
Note: There’s no direct cart session API; modifications only work indirectly through theme settings or product/customer data
Resolution Status:
The developer acknowledged the limitations and accepted there’s no straightforward solution for real-time data injection before email dispatch. A third-party app (Loloyal) was suggested as an alternative that handles guest rewards automatically.
Summarized with AI on October 25.
AI used: claude-sonnet-4-5-20250929.
I have a custom rewards program (external app) and am trying to send data about the points accrued from an order so it can be displayed in the order confirmation email. I have a trigger on the webhook: checkouts/start and checkouts/update, however, I am not sure where to store that data if a user is purchasing as a guest (Note: I have it working fine as an existing customer if I apply it to that customers’ meta fields).
I tried to assign a meta field using order, however, I am getting a: “ERR_NON_2XX_3XX_RESPONSE”, which I assume means that the order doesn’t exist yet as it’s still in the checkout flow.
I was wondering if anyone has tackled this before and/or has any suggestions. Thanks!
From the frontend use cart attributes to pass in existing data from the frontend through the checkout and to the order.
On the backend through the api cart attributes are referred to as custom attributes.
Otherwise for third party apps you need to consult their support.
If there is no customer the first problem is WHERE is that data stored or when is it generated.
And how do you access it on the frontend.
If it only exists after an order is placed, or accepted, or payment capture, i.e. it does not exists when the order notification is sent then it’s dead in the water.
And probably other missing parts of the process description; even if a customer/guest is in the checkout flow how is there any reward data at all if a purchase has yet to be made.
The reward data is processed on a separate server, currently initiated by a webhook. It’s done server-side (app-side) because a promotion might be running (i.e. adding bonus points, or something else). The purpose is to (in an order confirmation) say: “You received (new) points, giving you (total), with (x,y,z) bonuses”
I’m looking for a way to feed that data back to the (cart?) before the order has been created, during the checkout flow so I can access it in the order confirmation email.
Using the admin API, is there a way to modify the cart during the checkout flow?
I guess I could do an AJAX call after the checkout button has been pressed to inject this into the cart data too; but I figured there should be a way to do this via a webhook.
Until there’s better process detail it’s much easier to just do a heuristic and give an estimate.
Just go with “You earned more points ”.
[quote=“Ridge1388”]
currently initiated by a webhook
a way to feed that data back to the (cart?) before the order has been created,
[/quote]
Getting ahead of yourself if it’s not even know if/when that data even exists when .
When and where is that webhook called, if there’s a frontend form then it’s back to finding out where the data is put by the app , if it’s not private, and somehow reconciling the session for guests.
If the webhook is called after an order is placed this is DOA; so you’d need to just generate an estimate on the front end then fix with the correct data after the order is made.
Only indirectly by changing theme settings, modifying product or customer data.
Read: There is no cart session api in themes on the shopify online sales channel [1].
IF the data is available you’d use the scripttag api to more directly interact with the frontend through javascript.
There is an upcoming cart transformation api but that’s meant more for things like bundling not cart session changes as nothing like session is built into the BuyerIdentity or Cart objects.
Yeah, that’s what I figured. It feels like there should be an easier way to pass data to the order notification email before it sends. I can’t do it on order/create as the email sends out (what seems like) immediately – oh well.
Hi! @Ridge1388 If managing guest data is getting too complicated with your custom setup, would you consider migrating to Loloyal, which is one of the top-rated loyalty apps on the Shopify App Store
With Loloyal you don’t need to worry about where to store points for guest checkouts—the app gives you the flexibility to choose:
All customers (including guests) can earn points, refer friends, and join VIP incentives. Guests automatically get points when they place an order, and they’ll receive an email notification about it. To actually redeem their points, they’ll just need to create a store account later.
Or, if you prefer, you can limit participation only to customers who have an account.
If you set it to “all customers,” then guest shoppers are included from day one. All you’d need to do is prepare your email templates, and Loloyal’s automation takes care of the rest.
Hope it will help you solve the problem. If you’re interested, try Loloyal, which provides a 7-day free trial, plus 40% off your first month with this code: “LL40%OFF.” Shopify Apps