Filter an order via GET by using flags or note_attributes

rpfeil
New Member
1 0 0

Hi,

i am currently importing orders using REST, once imported I am marking them as imported by updating them with a flag and a note attribute.

Now I am trying to only GET the orders that don't have my flag/note attribute set.

 

How can I set the Parameter in my GET so that those orders get ignored?

0 Likes
Jayvin
Shopify Partner
147 21 34

Hi,

Well, I don't think there is any order api request that let's you filter orders by flag/note attribute.

What you can do is a combination of filters like created_at_min, created_at_max, since_id etc into your order request to filter out the orders that you have already imported.

https://shopify.dev/docs/admin-api/rest/reference/orders/order?api[version]=2020-07

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 221

For defining flags I typically use tags, as opposed to the note field. Since you can have multiple tags, and the note field is a one-shot deal. 

Here's a GraphQL example where I am pulling the 5 most recent orders that don't have imported defined in the tag values. The minus sign in the query specifies that I don't want the tag value to be imported. Should work fine!

{
  orders(first: 5, reverse: true, query: "-tag:imported") {
    edges {
      node {
        id
        name
        note
        tags
      }
    }
  }
}

 

0 Likes