checkout trigger on order complete

mikeyB999
Tourist
6 0 1

I am using the JS SDK to build shopify presence on my website. 

I figured how to build my own cart and open a checkout, submit line items and launch the checkout in a new web-browser.

My question is - how do i detect that an order was completed?

I see that there's an 'order' field in checkout - but do I have to keep polling this variable to figure out when/if  a checkout completed or is there some sort of event that i can trap?

I did notice that the checkout session pointed to by "webUrl" seems to send messages back to the window that called it which i can trap via window.onmessage() but i haven't figured out what these messages mean and if any of them flag that an order was complete.

 

Any help gratefully accepted 🙂

 

thanks! 

Replies 2 (2)
Gregarican
Shopify Partner
1030 86 276

Quickest thing to do would be to setup a webhook that would trigger upon order completion. Details here --> https://help.shopify.com/en/manual/orders/notifications/webhooks

mikeyB999
Tourist
6 0 1

ok - i guess it's ok to answer your own question:

 

Looks like this might be the answer: https://shopify.dev/docs/admin-api/rest/reference/events/event