Reputation: 43
I am creating a shopify app that queries the store for orders. The intention is to get BOTH unfulfilled and fulfilled orders; if you go to the orders tab of your store, I need to have returned all of the orders that are listed there. However, my current code will only return orders which are NOT fulfilled.
The query in question is as follows in Ruby on Rails:
@orders = Shopify_API::Order.find(:all)
I have even tried using a params of fullfillment_status: "any", which is the default indicated at https://help.shopify.com/api/reference/order so it shouldn't be necessary, but there was no change.
What am I not understanding or missing with this? If a fulfilled order is no longer considered a viable order or something, how do I go about querying for them anyway?
Thank you.
Upvotes: 2
Views: 1284
Reputation: 11427
You need to organize yourself better. Here are some tips based on what works well for me.
That about covers it. The fulfillment status is 'unshipped' for the unfulfilled, which is super intuitive eh?
page = 1
orders = []
status = { fulfillment_status: 'unshipped', status: 'open', financial_status: 'paid', limit: 250 }
count = ShopifyAPI::Order.count(status)
puts "Found #{count} UNSHIPPED OPEN PAID orders..."
if count > 0
page += count.divmod(250).first
while page > 0
status.merge!({ page: page })
orders += ShopifyAPI::Order.all(params: status)
page -= 1
end
end
Upvotes: 3