getting unfulfilled orders missing some orders?

Solved
Highlighted
Shopify Partner
21 2 1

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:

fulfillment_status

Filter orders by their fulfillment status.

(default: any)
  • shipped: Show orders that have been shipped. Returns orders with fulfillment_status of fulfilled.
  • partial: Show partially shipped orders.
  • unshipped: Show orders that have not yet been shipped. Returns orders with fulfillment_status of null.
  • any: Show orders of any fulfillment status.
  • unfulfilled: Returns orders with fulfillment_status of null or partial.

I thought using "unfulfilled" would meet our needs.  Am I using the wrong status?  Why does it work most of the time, then?

0 Likes
Highlighted
Shopify Partner
529 38 109

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:

https://{api_key}:{api_password}@{my_shop}.myshopify.com/admin/api/2020-07/orders/count.xml?fulfillm...

If the numbers seem way off compared to looking in the Shopify web admin there might be trouble!

0 Likes
Highlighted
Shopify Partner
21 2 1

In case anyone is wondering, I did two things:

  1. Used Greg's count trick to get count.  I use this mainly for logging.  If it was a perl script, I would use this to cycle through pages, but right now that is not needed.
  2. I made the following changes:
curl -i -X GET https://$ApiKey:$ApiPassword@$Store.myshopify.com/admin/api/2020-01/orders.xml?fulfillment_status=unfulfilled -H 'Cache-Control: no-cache'

to

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.

0 Likes