Next order "in line"

Hello @craspini!

The best way to achieve this is to use a query like the following one and check the back-ordered quantity for the line item that contains that product in each order.

query{
  orders(sku:"string" fulfillment_status:"string" order_date_from:"ISODateTime" order_date_to:"ISODateTime"){
    complexity
    request_id
    data(first:10 sort:"order_date"){
      pageInfo{
        hasNextPage
        endCursor
      }
      edges{
        node{
          legacy_id
          order_date
          line_items(first:2){
            pageInfo{
              hasNextPage
              endCursor
            }
            edges{
              node{
                sku
                backorder_quantity
              }
            }
          }
        }
      }
    }
  }
}

As you can see:

  1. I filtered the orders by those that contain that particular SKU.
  2. I am also using the fulfillment_status filter to avoid fetching fulfilled orders, as I don’t need them, and they will consume credits. Suppose you have many other than the default ones; you will need to query each separately.
  3. order_date_from and order_date_to are there if you have many orders per day and you’d rather filter even more.
  4. Orders are sorted by order_date, which is the day the order was created, so you can compare which one needs to be attended to first.
  5. Line items only return SKU and backorder_quantity. You will need to check if SKU matches the SKU you are looking for and if its backorder quantity is more than 0.

I hope I was clear enough. If not, please let me know!

Have a great day!
TomasFD