As a part of my shopify application I would like to keep a local export of every single one of my orders. I have a ruby script that achieves most of what I need here, but it only fetches unfulfilled orders.
I have tried tweaking ShopifyAPI::Order.all by adding parameters like so
fullfilled_orders=ShopifyAPI::Order.all(params: { status: 'any', fulfillment_status: 'fulfilled'})
I try variations of 'any' and 'fulfilled' for both fields, and even running it with no parameters, but the output stays the same.
The application has every possible permission in the store's settings page and the application scope in ruby is set to this
scope: 'read_all_orders read_orders read_customers read_users',
Here is a snippet of the function
def order_dl()
# Load API credentials from file
config = YAML.load_file('config.yml')
# Shopify API credentials
session = ShopifyAPI::Auth::Session.new(
shop: config['shop'],
access_token: config['access_token'],
)
ShopifyAPI::Context.setup(
api_key: config['api_key'],
api_secret_key: config['api_secret_key'],
api_version: '2024-01', # Example: '2024-01'
scope: 'read_all_orders read_orders read_customers read_users',
is_private: false, # Set to true if you are using a private app
is_embedded: true # Set to true if you are using an embedded app
)
ShopifyAPI::Context.activate_session(session)
client = ShopifyAPI::Clients::Rest::Admin.new(
session: session
)
test_session = ShopifyAPI::Context.active_session
#retrieve order details
orders = ShopifyAPI::Order.all(params: { status: 'any', fulfillment_status: 'any'})
infos=[]
It appears you are passing the options incorrectly. According to the docs
statusandfulfillment_statusare keyword arguments and should be passed as follows:Please note this will only retrieve the first 50 by default. API Docs.
You can set the limit to 250 using
limit: 250; however you cannot retrieve any more than 250 records at a time so to truly receive all of them you may have to loop this process multiple times using an offset likesinceorupdated_at_min