The search function in Admin can bring up orders when entering a tracking number, but on the graphql side the fulfillment
query only has id
as argument.
Is there a way to find which order a tracking number is attached to, without downloading all orders (with their fulfillments and trackings) and looping through them?
Thanks
Hi Daniel,
Currently, the Shopify GraphQL Admin API doesn’t provide a direct query to find an order by its tracking number. The fulfillment
query requires an ID as an argument, which means you can’t directly search for fulfillments using a tracking number.
To achieve your goal without downloading all orders, you could consider these workarounds:
- Store Tracking Numbers as Metafields: If you store tracking numbers as metafields on orders, you can use the
order
query with a metafield filter to find orders by tracking number. This requires setting up metafields for tracking numbers in advance.
- Use a Custom App: Develop a custom app that listens to fulfillment events and maintains a mapping of tracking numbers to order IDs. This app can then provide a service to query orders by tracking number.
- Batch Processing: If neither of the above options is feasible, you may need to periodically download order data and process it in batches to maintain a local mapping of tracking numbers to order IDs.
Hope this helps!
Hi Liam
Thanks for your help.
Regarding option 1, can you confirm that the orders
query can have a query filter by metafield? I can’t find it in orders - GraphQL Admin .