Is it possible to use the Products API to query based on order tag?

Solved
Tourist
6 0 0

For example I manually add "waiting for shipping" tag to several orders,
Is it possible to retrieve those orders details by using get order api call ?

0 Likes
Shopify Partner
1843 170 537

No and yes. The yes part is that you can create a saved search for your orders where tag equals "waiting for shipping" and then retrieve the orders for that saved search via

/admin/orders.json?saved_search_id=<SEARCH_ID>

Hope this helps!

I turn coffee in to code - since 1998
1 Like
Tourist
6 0 0

Hi, 
Thank you for your response so soon,

I am intent make a app to manager orders,
this app will retrieve all orders by api and automatic add tag for example "new" ,"waiting for shipping" etc. to orders based on orders status.
than user can click like "waiting for shipping" bottom to show all orders that have "waiting for shipping"  tag.

I want achieve this function using api , not by download all orders to my own database....

Is it sounds possible .....?

0 Likes
Highlighted

Success.

Shopify Partner
1843 170 537

If you do not want to persist some kind of order state on your app side, then yes, that does look like the only way you could distinguish new orders and different order states.

 

Personally, I'd prefer not to use tags or any other visible workaround that merchants can edit. For instance, a merchant could easily edit a tag that was added by your app and thereby break your app for that order. While that can count as a user error, it is always good to avoid allowing errors to happen in the first place. I'd also prefer not to use tags because it could interfere with a merchants existing tagging taxonomy, other apps that use tags etc.

 

But yes, tags would be one way of doing what you need without local database.

I turn coffee in to code - since 1998
1 Like
Tourist
6 0 0

Thank you very much!
this solved my problem!

0 Likes
Tourist
6 0 0

Hi, I only can find saved_search document here
https://help.shopify.com/en/api/reference/customers/customersavedsearch.

Could you tell me where to find the document about using savedsearch in orders?

Thank you

0 Likes
Shopify Partner
1843 170 537

Hey @nin-trnd 

 

Sorry, I totally screwed this one up. I had a false positive test case that made me assume using saved_search_id is okay on orders.json endpoint. It isn't and won't work :-(

 

It appears you won't be able to do this using REST Admin API. The query filter on the endpoint doesn't go, the saved search only works for customer resource as you already noted via docs and that doesn't leave you with more options within REST API.

 

If you are able to use a GraphQL client, the GraphQL Admin API does support many more fields in the query filter. I just confirmed that tag works as expected so you can also do

 

{
  orders(first:50, query:"tag:foo") {
    edges {
      cursor
      node {
        id
        name
        tags
      }
    }
  }
}

Once again, sorry for the confusion.

I turn coffee in to code - since 1998
1 Like
Tourist
6 0 0

Hi, KarlOffenberger
Its Ok ,No problem.


Thank you for helping me out,
I will check out the  solution.

Thank you very much!

0 Likes