How to retrieve an order via REST using the order number instead of the order ID?

HendersonP1
Tourist
4 0 1

Hey all!

We have built our own return system which acts as a private app in Shopify. Lately we have been getting a lot of issues from customers that can't find their order in the system, after debugging we realized that the way we are retrieving the order information sometimes works and sometimes it does not. 

We are aware that according to the documentation we should be retrieving the order information by using the "order ID". However, since this is a solution where the users can go and make the returns/exchange themselves, we are using the order name (which is shared in the email and in the confirmation page after a purchase). 

We are using the REST admin API  where we are adding the order name by adding it as a query param together with the status, at the end the endpoint at which we are making the request looks like:

https://${shopid}.myshopify.com//admin/api/2021-01/orders.json?name=#EXAMPLE1234&status=any


I have basically two questions:
1. Is there a way I could get the order ID by using the order number from the admin API?
2. Our customers have access to the Order Number, that's why we are using it to retrieve order data. Is there a way of a enabling them to get access to the order ID in case we can't get it ourselves using the API?



Thank you very much!
Replies 5 (5)

NicholasE
Visitor
2 0 1

We're seeing the same issue.  Previously when searching by order name we'd either get 1 or 0 results, the 1 being an exact match.  As of yesterday we get either 50 or 0 results and sometimes the order name we searched by isn't in the results at all.  We verified the order exists by logging into the dashboard, but the orders api is not returning it.  I'm guessing that if we started paginating through the results we might find it, but the api has never required that before.  There's a definite bug in the search that was introduced around 7am PST yesterday.

HendersonP1
Tourist
4 0 1

This was exactly what we experienced, I am a bit worried about our current setup since I can't find it anywhere in the official documentation so issues like these are likely to happen again.

Dive
Shopify Partner
23 1 1

Hello @HendersonP1 

To have a better understanding of your return system, correct me if i'm wrong :

- You have created a private app where your clients can do their refunds
- There is a (i assume) a search input, where they can put their Order Name (#1234)

From here, what are you doing ? Firing an API call, based on user's input and displaying the result in a page ?

1) With the API call you just wrote you will find the order's id.
As a response, you should see all fields that are already include inside order's object including the ID (which you can target by using order.id).
If you only want this field, you can also lighten the query by using -> fields=id. It will only show you the fields that you request.
If sometimes your customer can't find their order, maybe add a fallback system where they can can put their order id (see below) (your can use this endpoint if you have the order.id -> orders/{order_id}.json)

2) Apparently the confirmation page includes the checkout object. Regarding the documentation, you can have access to the order_id with the checkout object. (checkout.order_id)

- Link where you 'll find your confirmation page settings : https://{your_shop}.myshopify.com/admin/settings/checkout

- Article about how to customize confirmation page

Hope it will help !
Thomas.

E-commerce analytics should be easier, that is why we have created diveanalytics.co
NicholasE
Visitor
2 0 1

Shopify doesn't seem to keep closed incidents in their status page, but they acknowledged there was a bug in the orders search and deployed a fix.  The issue is resolved for us.

HendersonP1
Tourist
4 0 1

Yes all your assumptions were right about how our system works.

And the API call will return the order ID as long as it is found. The issue is that sometimes our API call does not return any order that matches the Order Name and therefore I can't get the Order ID.

Including the order_id in the checkout page helps but only for those orders that are already created when the user reaches this page (which is not always the case).

However, thank you very much for your time and effort put into your reply, definitely a lot of useful information 🙂