HowTo: find an order via API call using order_number?

Dan_Chow
Shopify Partner
19 0 3

Hello,

I have had some trouble finding an order using a query in the API. The following address works as expected when entered into the browser navigation bar, but not when entered into the RESTful API:

https://texansaddles-com.myshopify.com/admin/orders/search.json?query=order_number:1066

Is there an alternate format to consider when querying through the API?

I see that the search.json endpoint function works for the customer resource, but apparently not for the orders resource. How might one look up an order through the API by referencing the order_number parameter? (This is the number my customers have to reference their order).

Any advice helps, thanks!

0 Likes
Colin18
New Member
4 0 0

According to the docs you should be able to do this

Do a GET request on 

https://texansaddles-com.myshopify.com/admin/orders/1066.json

or individual fields, like the example below

https://texansaddles-com.myshopify.com/admin/orders/1066.json?fields=id,line_items,name,total_price


 
0 Likes
Dan_Chow
Shopify Partner
19 0 3

This example works for an order ID (Shopify unique numeric identifier), but not for the order parameter "order_number" (order 'name' given at checkout).

0 Likes
Colin18
New Member
4 0 0

I see what you mean, did you try 

https://texansaddles-com.myshopify.com/admin/orders?query=1066

Sorry I don't have my API currently configured so I couldnt' test this manually myself.

0 Likes
Jamie_D_
Shopify Staff (Retired)
Shopify Staff (Retired)
531 1 99

Hi Dan,

You can search by order number by performing the following:

GET https:/texanssaddles-com.myshopify.com/admin/orders.json?name=1066

 

Dan_Chow
Shopify Partner
19 0 3
OK, thank you.

The API docs are unclear and might need an update on this as I tried a number of different versions of this request unsuccessfully. (The name parameter is associated with a string with a leading # but including the # retrieves all orders, not the one searched for).

order_number searches after this fashion also retrieves all records and not the searched for one.

 

Thank you again for pointing me right.

0 Likes
VamVinDev
Tourist
4 0 3

You should be getting any order by just attaching another query parameter called "status=any"

Ex. : https://storeName.myshopifycom/admin/orders.json?name=12345&status=any

jasper5
Shopify Partner
9 0 1

 

Is it possible to fulfill order using order name? 

I'm thinking of something below:

 

POST: /admin/orders/{{ order_id}}/fulfillments.json?name=12346

0 Likes
happy_shopper
New Member
1 0 0

VaMVinDev - thanks, that is not all intuitive, and the docs could do with being a lot better

0 Likes
Izzyfsol
New Member
1 0 0

Anyone know how to stop it pulling back more than the one asked for?

When I call for this I get every variation of 1011XXX

https://x.myshopify.com/admin/api/2020-04/orders.json?name=1011&status=any&fields=id

{
"orders": [
{
"id": 2168310530141,
"name": "#10119"
},
{
"id": 2168126570589,
"name": "#10118"
},
{
"id": 2167977476189,
"name": "#10117"
},
{
"id": 2167957815389,
"name": "#10116"
},
{
"id": 2167937728605,
"name": "#10115"
},
{
"id": 2167912136797,
"name": "#10114"
},
{
"id": 2166914056285,
"name": "#10113"
},
{
"id": 2166864838749,
"name": "#10112"
},
{
"id": 2166811787357,
"name": "#10111"
},
{
"id": 2166799630429,
"name": "#10110"
},
{
"id": 140100829210,
"name": "#1011"
}
]
}

0 Likes