Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Python API customer.orders() empty

Python API customer.orders() empty

codyk12
Visitor
1 0 0

I have an issue with the Python API package.

 

The customer.orders() function will not find all the orders associated with the given customer.

 

For example I have a customer with an order count of 1.

shopify.Customer.find(407915331645)

 => customer(407915331645)

shopify.Customer.find(407915331645).orders_count

 => 1

shopify.Customer.find(407915331645).orders()

 => []

shopify.Order.find(380765536317)

 => order(380765536317)

shopify.Order.find(380765536317).customer

 => customer(407915331645)

shopify.Order.find(380765536317).customer.orders()

 => [] 

 

The customer.orders() function returns an empty list when I know for certain there is an order tied to that account. The last line clearly illustrates the issue.

 

Not sure if this the Python packages fault or the API fault. Any help would be appreciated.

 

Reply 1 (1)

GrahamS
Shopify Staff (Retired)
193 37 55

Hey @codyk12 ,

 

We touch on this in the API FAQ - if the order in question is older than 60 days and you are unable to successfully retrieve the data via API, you may be missing the necessary scope "read_all_orders". Querying for orders that are older than 60 days with only "read_orders" will typically return an empty array, like what you are seeing here.

 

I would check to see if your order is greater than 60 days old, and if so, make sure your app has the "read_all_orders" scope applied before trying again.

 

Best,

To learn more visit the Shopify Help Center or the Community Blog.