I am running the following to get all unfulfilled orders:
Store=$1 ApiKey=$2 ApiPassword=$3 curl -i -X GET https://$ApiKey:$ApiPassword@$Store.myshopify.com/admin/api/2020-01/orders.xml?fulfillment_status=unfulfilled -H 'Cache-Control: no-cache'
It works perfectly most days, but then suddenly we will see older orders that are unfulfilled show up in the results. For instance, looking directly in shopify admin, I see an order where the confirmation was sent out on 7/23/2020 and is definitely still unfulfilled today ( 8/25/2020 ), but for some reason we never saw it before today in the results of the above command. What is happening? What status would it need to be in in order to not be seen as "unfulfilled"? Why would an older order suddenly show up today?
As another example, I have one order I see in the admin that I don't see in any listing of unfulfilled orders using the above command earlier today ( between 1 and 2 am EST ), but I ran the same command at 2 pm EST and it worked fine, showing the order. In fact, the command I just ran showed a bunch of orders that did not show up first thing this morning. Some are no doubt new orders created today, but some are older orders. Some of the new orders have refunds, but not all. Why is this happening? Is it a time of day issue?
Yes, I am using "orders.xml" on purpose, because I want the XML response, and that works fine.
According to https://shopify.dev/docs/admin-api/rest/reference/orders/order, specifically the section below:
Filter orders by their fulfillment status.(default: any)
I thought using "unfulfilled" would meet our needs. Am I using the wrong status? Why does it work most of the time, then?
Solved! Go to the solution
This is an accepted solution.
Does the response provide more than a single page? If so, there are apparent issues with cursor-based pagination based on other threads on here. One thing you could try periodically as a manual sanity check is just pull a count. Like this:
If the numbers seem way off compared to looking in the Shopify web admin there might be trouble!
In case anyone is wondering, I did two things:
curl -i -X GET https://$ApiKey:$ApiPassword@$Store.myshopify.com/admin/api/2020-01/orders.xml?fulfillment_status=unfulfilled -H 'Cache-Control: no-cache'
curl -i -X GET https://$ApiKey:$ApiPassword@$Store.myshopify.com/admin/api/2020-01/orders.xml?fulfillment_status=unfulfilled&limit=250 -H 'Cache-Control: no-cache'
So now it gets 250 orders at a time, instead of the default 50. Since it gets orders in reverse order, and since anything beyond 250th order is old and really should be cancelled or fulfilled in Shopify (I assume they fulfilled or cancelled the order outside of shopify), this works for us. We might need to adjust it later, as we learn more.