Draft orders - do we need to use polling?

nmmlon
New Member
5 0 0

Hi all,

we're using draft orders to calculate order cost, amongst other things. The docs mention that some draft orders may need polling to get the correct price:

https://shopify.dev/docs/admin-api/rest/reference/orders/draftorder#create-2020-07

When you create and update draft orders some calculations are done asynchronously, such as calculating shipping and taxes. There might be times when a draft order is created but these calculations haven't completed. In these cases, you need to poll the draft order until the calculations are finished.

We have never come across any draft orders that actually require polling. Can someone provide more information on the circumstances under which polling is necessary? Have others implemented polling or are you just using the draft order that comes back from the API?

Thanks in advance,

Nils

 

 

 

0 Likes
tolgapaksoy
Shopify Partner
67 5 32

If you require polling for your DraftOrder, the REST api will respond to your POST or PUT operation with a 202 Accepted header.

If this is the case, you should be polling the DraftOrder until it changes to 200 OK.

0 Likes
nmmlon
New Member
5 0 0

Hi 

0 Likes
tolgapaksoy
Shopify Partner
67 5 32

It usually happens for us when changing shipping or billing address, for calculating tax rates or adding a shipping line.

0 Likes
nmmlon
New Member
5 0 0

Useful to know, thanks for your reply.

0 Likes
_JB
Shopify Staff
Shopify Staff
750 86 163

Hey @nmmlon,

As mentioned already, a 202 is only returned if shipping+tax calculations need extra time. This usually happens if a shop uses an external service for tax or shipping, or in rare cases when the Shopify platform is under heavy load. In most cases however, you can expect a 200 response.

If you want to test this, try loading up a draft order with multiple unique SKUs to increase the number of calculations that need to happen.

JB | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes
nmmlon
New Member
5 0 0

Thanks @_JB , I appreciate the response!

0 Likes