Getting the shipping rate id from order using API

Solved
Shopify Partner
10 0 2

If we look at the Shipping Zones API then there are basically three types of rates:

  • weight_based_shipping_rates
  • price_based_shipping_rates
  • carrier_shipping_rate_providers

 

When an order is placed with a shipping method setup in Shopify->Settings->Shipping->Shipping rates at checkout, then  it can either be a weight based or price based shipping rate. Information about the orders shipping method is found in the shipping_lines part of the Orders API:

"shipping_lines": [
  {
    "code": "INT.TP",
    "price": "4.00",
    "price_set": {
      "shop_money": {
        "amount": "4.00",
        "currency_code": "USD"
      },
      "presentment_money": {
        "amount": "3.17",
        "currency_code": "EUR"
      }
    },
    "discounted_price": "4.00",
    "discounted_price_set": "4.00",
    "source": "canada_post",
    "title": "Small Packet International Air",
    "tax_lines": [],
    "carrier_identifier": "third_party_carrier_identifier",
    "requested_fulfillment_service_id": "third_party_fulfillment_service_id"
  }
]

My question is: Does anybody know how one can correlate shipping method from an order to the rates in the Shipping Zone API?

 

As far as I can see, then the only way to do this is to compare the frontend title which is seen in the fields:

weight_based_shipping_rate.*.name
shipping_lines.*.title

But the problem is that these titles are often updated.

0 Likes
Highlighted

Success.

Shopify Staff
Shopify Staff
1127 79 162

Hey there, 

 

I would really quite enjoy someone proving me wrong here, but I don't think you'll find any reliable solution for this unfortunately. 

 

The reason for this being that as you said the shipping rate names could change at any time, but that won't update them on the order that was already placed. But to add to that, there's nothing stopping a shop from having two identically named shipping rates. 

1 Like
Highlighted
Shopify Partner
10 0 2

I really appreciate a straight answer and we will work from the names then. Thank you for the answer @Josh

0 Likes