How to find SKUs associated with shipping labels

We need to identify the SKUs associated with each tracking number on a shipment. If an order contains 2 SKUs, and each SKU is shipped in a different package, we need the ability to capture the tracking number for each SKU.

Is this possible by querying Shipments? It appears the response contains all items/quantities shipped and then the shipping labels (tracking numbers) as a separate array. I don’t see an id that would associated a shipped line with a tracking label.

Has anyone been able to identify the tracking number/shipping label for each SKU?

Hi @isaac.wyatt!
Would a query like this one work for you?:

query {
  order(id: "125450668") {
    request_id
    complexity
    data {
      id
      legacy_id
      order_number
      shipments {
        id
        shipping_labels {
          tracking_number
          shipment_line_items(first: 10) {
            edges {
              node {
                id
                line_item {
                  sku
                }
              }
            }
          }
        }
      }
    }
  }
} 

This way you can see the shipments for an order, each shipment with the tracking number and the line items included on that label/shipment/tracking_number

Let me know if this won’t work for you.
Thanks in advance!
Tom

Wow, this is excellent @tomasw. Really appreciate the quick feedback.

1 Like

Hi @tomasw - a follow up here. This query does well to define the SKU associated with each shipping label. I would also like to see the quantity associated of the SKU on each shipping label. Ex: 5 units of Item A shipped on Label1 and 3 units of Item A shipped on Label2.

When I add the “quantity” field to this query, the total ordered quantity for the line is returned (i.e. 8 units from the example above). Any recommendations on how to get the specific quantity per shipping label? This data is available in the UI.

Hi @isaac.wyatt!
Are you adding quantity at the line_item level or at the shipment_line_item level?
In case it helps, it should be at the shipment_line_item level, like:

query {
  order(id: "142907492") {
    request_id
    complexity
    data {
      shipments {
        id
        shipping_labels {
          tracking_number
          shipment_line_items(first:10) {
            edges {
              node {
                id
                quantity
                line_item {
                  sku
                }
              }
            }
          }
        }
      }
    }
  }
}

Hi @tomasw adding the quantity (and quantity_shipped) only returns the total quantity across all packages. Please see the example below. This sku (3079) was actually shipped across 3 packages, with different quantities in each, with a total ordered/shipped quantity of 10.

query {
  order(id: "148606821") {
    request_id
    complexity
    data {
      id
      legacy_id
      order_number
      shop_name
      fulfillment_status
      order_date
      required_ship_date
      shipping_address {
        first_name
        last_name
        address1
        address2
        city
        state
        state_code
        zip
        country
      }
      shipments {
        id
        order_id
        shipping_labels {
            id
            tracking_number
            carrier
            shipping_name
            shipping_method
            cost
            carrier_account_id
            created_date
            shipment_line_items(first: 20) {
            edges {
              node {
                id
                line_item {
                  id
                  sku
                  partner_line_item_id
                  quantity
                  quantity_shipped
                  fulfillment_status
                  shipped_line_item_lots{
                    id
                    line_item_id
                    lot_id
                    lot_name
                    lot_expiration_date
                }
                }
              }
            }
          }
          }
      }
    }
  }
}

Response
{
“data”: {
“order”: {
“request_id”: “5f6cb47ef5c50d9b8c97525d”,
“complexity”: 21,
“data”: {
“id”: “T3JkZXI6MTQ4NjA2ODIx”,
“legacy_id”: 148606821,
“order_number”: “90210004”,
“shop_name”: “STORD”,
“fulfillment_status”: “fulfilled”,
“order_date”: “2020-09-22T00:00:00+00:00”,
“required_ship_date”: “2020-09-09T00:00:00+00:00”,
“shipping_address”: {
“first_name”: “Isaac”,
“last_name”: “Wyatt”,
“address1”: “Address Data”,
“address2”: null,
“city”: “City”,
“state”: “State”,
“state_code”: null,
“zip”: “Zip”,
“country”: “US”
},
“shipments”: [
{
“id”: “U2hpcG1lbnQ6MTAxMjk1NTQ5”,
“order_id”: “T3JkZXI6MTQ4NjA2ODIx”,
“shipping_labels”: [
{
“id”: “U2hpcHBpbmdMYWJlbDo3MzMwODY2OQ==”,
“tracking_number”: “1Z87VY021214635017”,
“carrier”: “ups”,
“shipping_name”: “Manual Order Shipping Method”,
“shipping_method”: “UPS 3 Day Select”,
“cost”: “482.06”,
“carrier_account_id”: “XXXX”,
“created_date”: “2020-09-22T15:21:06+00:00”,
“shipment_line_items”: {
“edges”: [
{
“node”: {
“id”: “U2hpcHBlZExpbmVJdGVtOjE4MDgzODM0Mg==”,
“line_item”: {
“id”: “TGluZUl0ZW06NDIyMDM5MzIz”,
“sku”: “3079”,
“partner_line_item_id”: “90210014__1__S”,
“quantity”: 10,
“quantity_shipped”: 10,
“fulfillment_status”: “fulfilled”,
“shipped_line_item_lots”: []
}
}
},
{
“node”: {
“id”: “U2hpcHBlZExpbmVJdGVtOjE4MDgzODM2NQ==”,
“line_item”: {
“id”: “TGluZUl0ZW06NDIyMDM5MzI0”,
“sku”: “27201”,
“partner_line_item_id”: “90210014__2__S”,
“quantity”: 5,
“quantity_shipped”: 5,
“fulfillment_status”: “fulfilled”,
“shipped_line_item_lots”: []
}
}
}
]
}
},
{
“id”: “U2hpcHBpbmdMYWJlbDo3MzMwODY3MA==”,
“tracking_number”: “1Z87VY021201771626”,
“carrier”: “ups”,
“shipping_name”: “Manual Order Shipping Method”,
“shipping_method”: “UPS 3 Day Select”,
“cost”: “0.00”,
“carrier_account_id”: “109530”,
“created_date”: “2020-09-22T15:21:06+00:00”,
“shipment_line_items”: {
“edges”: [
{
“node”: {
“id”: “U2hpcHBlZExpbmVJdGVtOjE4MDgzODM0Nw==”,
“line_item”: {
“id”: “TGluZUl0ZW06NDIyMDM5MzIz”,
“sku”: “3079”,
“partner_line_item_id”: “90210014__1__S”,
“quantity”: 10,
“quantity_shipped”: 10,
“fulfillment_status”: “fulfilled”,
“shipped_line_item_lots”: []
}
}
}
]
}
},
{
“id”: “U2hpcHBpbmdMYWJlbDo3MzMwODY3MQ==”,
“tracking_number”: “1Z87VY021208358838”,
“carrier”: “ups”,
“shipping_name”: “Manual Order Shipping Method”,
“shipping_method”: “UPS 3 Day Select”,
“cost”: “0.00”,
“carrier_account_id”: “109530”,
“created_date”: “2020-09-22T15:21:06+00:00”,
“shipment_line_items”: {
“edges”: [
{
“node”: {
“id”: “U2hpcHBlZExpbmVJdGVtOjE4MDgzODM1OQ==”,
“line_item”: {
“id”: “TGluZUl0ZW06NDIyMDM5MzIz”,
“sku”: “3079”,
“partner_line_item_id”: “90210014__1__S”,
“quantity”: 10,
“quantity_shipped”: 10,
“fulfillment_status”: “fulfilled”,
“shipped_line_item_lots”: []
}
}
},
{
“node”: {
“id”: “U2hpcHBlZExpbmVJdGVtOjE4MDgzODM4Ng==”,
“line_item”: {
“id”: “TGluZUl0ZW06NDIyMDM5MzI0”,
“sku”: “27201”,
“partner_line_item_id”: “90210014__2__S”,
“quantity”: 5,
“quantity_shipped”: 5,
“fulfillment_status”: “fulfilled”,
“shipped_line_item_lots”: []
}
}
}
]
}
}
]
}
]
}
}
}
}

Hi @isaac.wyatt
I see that, thanks for the Query!

So in that case you need to look for quantity at the shipment_line_items level, try using this one:

query {
  order(id: "148606821") {
    request_id
    complexity
    data {
      id
      legacy_id
      order_number
      shop_name
      fulfillment_status
      order_date
      required_ship_date
      shipping_address {
        first_name
        last_name
        address1
        address2
        city
        state
        state_code
        zip
        country
      }
      shipments {
        id
        order_id
        shipping_labels {
          id
          tracking_number
          carrier
          shipping_name
          shipping_method
          cost
          carrier_account_id
          created_date
          shipment_line_items(first: 20) {
            edges {
              node {
                id
                quantity
                line_item {
                  id
                  sku
                  partner_line_item_id
                  quantity_shipped
                  fulfillment_status
                  shipped_line_item_lots {
                    id
                    line_item_id
                    lot_id
                    lot_name
                    lot_expiration_date
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

As you see I changed this part

shipment_line_items(first: 20) {
            edges {
              node {
                id
                line_item {
                  id
                  sku
                  partner_line_item_id
                  quantity

and “moved” the quantity to the shipment_line_items section:

shipment_line_items(first: 20) {
            edges {
              node {
                id
                quantity
                line_item {
                  id
                  sku
                  partner_line_item_id

What this does is that it Queries for the quantity at the shimpent_line_items level, because if you add the line_items connection there it will be querying for the line items at the order level and not the shipment level (sorry if this sounds confusing)

Let me know if by using that query it still not clear.
Thanks again!
Tom

Wow! This makes sense. Thank you sir!

1 Like