Shipments Query (how to get order_date, order_number and line item total)

Hello,
how to get the shipments order number (not id), order_date because i’m only getting shipping date
and line items total
thanks

the query i’m using

      query {
          shipments{
            request_id
            complexity
            data(last:20) {
              edges {
                node {
                  id
                  legacy_id
                  order_id
                  user_id
                  warehouse_id
                  pending_shipment_id
                  address {
                    name
                    address1
                    address2
                    city
                    state
                    country
                    zip
                    phone
                  }
                  shipped_off_shiphero
                  dropshipment
                  created_date
                  line_items(first: 50){
                    edges {
                      node {
                        quantity
                      }
                    }
                  }
                  shipping_labels {
                    id
                    legacy_id
                    account_id
                    tracking_number
                    carrier
                    shipping_name
                    shipping_method
                    cost
                    profile
                    packing_slip
                    warehouse
                    insurance_amount
                    carrier_account_id
                    source
                    created_date
                  }
                }
              }
            }
          }
        }

Hi @karimedrees,
Please send a request-id and I can take a closer look. Thanks in advance!

Hi @Theresa
the request id is 616b2d9cd3948677bef37a0f

please note that i need to get the order number ,order date and line items total for each shipment

thanks

Hi @karimedrees,
If you have the order id, you can run the order query, and it will have the order number, order date, and the shipments with line item data associated with that order. That is a slightly different way to get all the information in one query. Not sure if it will work for you to associate it this way, but all the information you asked for is available.

query {
  order(id: "<order_id here>") {
    request_id
    complexity
    data {
      order_number
      order_date
      shipments {
        line_items {
          edges {
            node {
              line_item_id
              line_item {
                subtotal
              }
            }
          }
        }
      }
    }
  }
}

Hello again @Theresa
Thanks for your help, but can i get these information along with the shipments query
because i don’t want to make a alot of queries in order to list the shipments information
thanks again

Hi @karimedrees!

Would a Query like this work for you?

query {
  shipment(id: "the_shipment_id") {
    request_id
    complexity
    data {
      order {
        order_date
        order_number
        line_items(first: 5) {
          edges {
            node {
              id
              quantity
            }
          }
        }
      }
      line_items(first: 5) {
        edges {
          node {
            line_item_id
          }
        }
      }
    }
  }
}

This will return you the values needed from the Shipment ID.
Keep in mind that not all of the line items from the order can be found on the Shipment (for example, in orders partially shipped)

On the other hand, we recommend using webhooks to get the line items from the shipments, something like this:

https://developer.shiphero.com/webhooks#shipment-update-webhook

Which shouldn’t consume credits.

Please let us know if that doesn’t help.
Thanks in advance!
Tom