I made a custom app under settings → apps → develop app and have used it to connect to 2 webhooks: draft_order_create and order_create.
I set up the webhooks to retrieve the draft_order, or order and attach a note in our format. BYB-ORD-2411-0023412. (2411 = YYMM, Nov 2024). It works, and I can see that the API server is handling everything well.
INFO:api.main:Custom ID and attributes set for ORD 6069430681841
INFO:api.main:Webhook processed in 0.442 seconds for order 6069430681841
NFO:httpx:HTTP Request: PUT https://xxx.myshopify.com/admin/api/2023-10/draft_orders/11
I was able to use this to replace the ordered with {{ draft_order.note }}. In the admin panel, I would create a draft order, add an item, and when I went to send it… I would see the API server clicking away, and when I would send an email… it would show up with the correct order IDs. Invoice BYB-ORD-2411-0023412. I thought I was a genius.
I had to rebuild the server today, and so I re-added my API server from github. It is the same code. However, now when it runs, there is no notes on the order when the email pops up. If I refresh the screen, I can see the note has been added… but the email will ignore the note. I suspect it could be timing. Maybe I got lucky last week, and today the internet is a little slower.
I cannot figure out how to make this synchronous, so the next step won’t start before I finish modifying the order from my API. (I have tried attributes, tags as well… but all appear as blank).
What is the proper way to do this? I suspect its not with webhooks as these are asynchronous. It is strange that even after the note is there… the email ignores it.
Here is proof that the webhook APIs are working:
This is the draft_order template
And this is the dam subject! No notes displayed.


