Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hi. I'm wondering if I can
I'm using the Shopify python module and making requests like this:
f = shopify.Order.find(created_at_min="2022-06-09",fulfilled_status="fulfilled")
# (https://mystore.myshopify.com/admin/api/2022-04/orders.json?created_at_min=2022-06-09&fulfilled_stat...)
u = shopify.Order.find(created_at_min="2022-06-09",fulfilled_status="null")
I've also tried status=fulfilled, removing the date: .find(fulfilled_status="fulfilled")
None of it seems to filter by fulfillment status. Do I need to do this with the GraphQL endpoint?
Thanks much.
–Mike
Solved! Go to the solution
This is an accepted solution.
And the answer to the original question (doing it with just the REST API):
Which produces, via. the Python API:
.myshopify.com/admin/api/2022-04/orders.json?status=%3Cbuilt-in+function+all%3E&created_at_min=2022-05-22&fulfillment_status=shipped
Have a good one.
Update I am now working with the GraphQL library, but still struggling to filter by fulfillment status:
graphql_query = (
"""{
orders(first: 100, query: "fulfillment_status:FULFILLED updated_at:>"""
+ since_date
+ """") {
edges {
node {
id
displayFulfillmentStatus
updatedAt
}
}
}
}
"""
References: Field Search, Orders.
Input would, of course, be very much appreciated.
Here's a solution:
def get_orders(self, days_ago: int) -> dict:
"""
Get a list of shopify order resource objects.
"""
start_at = datetime.date.today() - datetime.timedelta(days=days_ago)
since = start_at.strftime("%Y-%m-%d")
graphql_query = (
"""{
orders(first: 100, query: "fulfillment_status:shipped updated_at:>"""
+ since
+ """") {
edges {
node {
id
displayFulfillmentStatus
updatedAt
}
}
}
}
"""
)
_response = shopify.GraphQL().execute(graphql_query)
_remote_orders = json.loads(_response)["data"]["orders"]["edges"]
return [item["node"] for item in _remote_orders]
Not sure why the API seems to ignore the filter parameter when I filter by a filter status that doesn't exist, though. (fulfillment_status:fulfilled). This post was key.
This is an accepted solution.
And the answer to the original question (doing it with just the REST API):
Which produces, via. the Python API:
.myshopify.com/admin/api/2022-04/orders.json?status=%3Cbuilt-in+function+all%3E&created_at_min=2022-05-22&fulfillment_status=shipped
Have a good one.