What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Is it possible to get the shipping rate from an order?

Is it possible to get the shipping rate from an order?

Esign
Shopify Partner
3 0 0

Hi,

I was wondering if it is possible to get the shipping rate id from an order. The only data that seems useful to me is the one under shipping_lines.
At the moment I collect the rate by first looking for the correct shipping zone based on, among other things, the country of the destination. And then I look at the correct rate based on the code in the shipping lines of the order. But the problem with this is when a shipping zone has rates with the same name... So I hope there are better methods, because this one is not really waterproof.

Thanks in advance!

Replies 2 (2)

Alan
Shopify Staff
129 15 25

Hi @Esign - thanks for getting in touch. I definitely understand where you're coming from here - it can be a little difficult to parse multiple IDs. At the moment, you're definitely correct that the information under shipping_lines would be the most relevant when you're querying orders. An example query you might want to take a look at would look something like this:

shippingLines(first: 5) {
        nodes {
          id
          code
          source
          title

 

This would give you a little more detail on each order's shipping rate and could better help parsing between the different ones by including the id, source and title of each one. I'd recommend following this format for sure, if you're not doing so already. 

 

At the moment this would be the best way to source this shipping rate data per order - but I hope this helps and provides some next steps for you. 

 

Cheers!

Alan | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

guest4
Shopify Partner
103 7 24

@Alan@ShopifyDevSup,

Should this be taken to mean that:

 

 

{
fulfillmentOrder(id:"gid://shopify/FulfillmentOrder/1234567890"){
    order{
      shippingLine{
        code
      }
    }
  }
}

 

 

Would return the shipping line for that particular fulfillment order and not a presumably random shipping line (in the event that there are multiple fulfillment orders for the order and assuming that there would ever be more than one shipping line per order)?