Get the orders by product id using graphql

Vamshi481
Tourist
4 0 0

I have a requirement of getting orders by product id using GraphQL, I did lots of research to do this but I'm unable to find a query to get this job done if someone could help me on this 

0 Likes
PersistentDev
Tourist
5 0 1

Hey, any progress on that?

If no, I'll join the question.

It's an absurdly simple task, but the solution seems to be non-existent.

Any official answer from Shopify?

0 Likes
Tiber
Tourist
10 2 0

Hey,

 I have sort of found a way to do this. I have a webhook that listens for checkout and then I take the list of products ids in the order and add them as tags to the order. Then I can use Graphql to request all orders with a specific tag.

{
  orders(first:10,query:"tag:onsale") {
    edges{
      node{
       id
        lineItems(first:10){
          edges{
            node{
              id
              name
            }
          }
        }
      }
    }
  }
}

 

0 Likes