Is there a way to populate order/tags field in API?

tony_data
New Member
5 0 0

We have two locations set up at the moment, we have an integrated WMS with our Shopify store, we do NOT want pull orders via the API from one of the locations, so we were hopeful we could use the orders/tags field to filter out this location when it hits our WMS.

Is there way for us to populate this field somewhere so the data is passed out in the API?

Or is there a better way?

I'm no API expert, which is why I am asking here!

Any help would be really appreciated.

 

0 Likes
Greg_Kujawa
Shopify Partner
965 80 204

If you use the Shopify GraphQL then you can query the shop orders (https://shopify.dev/docs/admin-api/graphql/reference/object/order?api[version]=2020-07), pulling both the sale channel (e.g. - Point of Sale, Online Store, etc.) as well the sale location for POS. Here's an example, where I am pulling the 20 most recent orders and getting this information. Of course the various other order data fields would also be available. This is just a quick sample. Hope this helps!

{
  orders(first: 20, reverse: true) {
    edges {
      node {
        id
        createdAt
        publication {
          id
          name
        }
        physicalLocation {
          id
          name
        }
      }
    }
  }
}

 

0 Likes
tony_data
New Member
5 0 0

Hi Greg! Thanks for coming back to me, maybe wasn't clear in my qustion... this is from my WMS dev team...

"Can the store populate the 'tags' field (or any other field) to reliably distinguish orders to be fulfilled from the XXXX location?

0 Likes
Greg_Kujawa
Shopify Partner
965 80 204

When you ask if "the store" can create a tag for an order, do you mean that a store employee would go into the Shopify web admin, pull up an order, and through that assign a tag? Yes, that's certainly possible. Although a manual process. And tags are essentially freetext fields. So for example, one employee could add a "Store 1" tag to an order. While another employee could add a "Store1" tag to another order. And yet another employee could add a "Store #1" tag to a different order. So these are prone to human error.

You (or your WMS team) can programatically add tags to existing orders via the Shopify API (please see GraphQL example below). But if you're going to that length you could just determine which specific location handled an order via the API example I provided. The tag field is just another step that's really not necessary.

 

{"query":"mutation tagsAdd($id: ID!, $tags: [String!]!) {
  tagsAdd(id: $id, tags: $tags) {
    node {
      id
    }
    userErrors {
      field
      message
    }
  }
}","variables":{
  "id": "{your_order_id}",
  "tags": [
    "Store 1"
  ]
}
}

 

0 Likes