Shipping Zones Api delivers inconsistent results

Solved
ShopDoctors
Excursionist
31 2 1

Explanation of edge case scenario:

1. I set my shop's default weight unit to pounds.

2. I create a shipping rate for orders weighing 0 to 5 pounds, rate price is $5

3. (later on) I change my shop's weight unit to ounces because most of my products are actually very small.

4. I create a new shipping rate for orders weighing 0 to 12 ounces, rate price is $3

Now, an app that calculates shipping estimates needs to get the shipping zones, so that they can calculate an estimate. The app gets:

{
"price": "5.00",
"weight_low": null,
"weight_high": 5
},
{
"price": "3",
"weight_low": 0,
"weight_high": 12
}

And the response of the shop.json endpoint says the shop's weight unit is ounces, while the rates do not return what unit they're using 😞

 

Problem:

Are the rates for 5lb and 12lb? Or 5oz and 12oz?

 

Solution:

Please add weight_unit to the shipping zone weight-based rates.

Accepted Solution (1)

Accepted Solutions
ShopDoctors
Excursionist
31 2 1

This is an accepted solution.

I figured it out... Shipping Zones are already available in GraphQl, however they are named Delivery Profile: 

https://shopify.dev/api/admin/graphql/reference/shipping-and-fulfillment/deliveryprofile

Using GraphQl you can get the shipping zones setup with the necessary weight units and currency codes, both of which can be inconsistent between different rates.

Example:

{
  deliveryProfiles(first:1) {
    edges {
      node {
        profileLocationGroups {
          locationGroupZones(first:10) {
            edges {
              node {
                methodDefinitions(first:10, eligible: true) {
                  edges {
                    node {
                      active
                      name
                      methodConditions {
                        field
                        operator
                        conditionCriteria {
                          __typename
                          ... on Weight {
                            value
                            unit
                          }
                          ... on MoneyV2 {
                            amount
                            currencyCode
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

 

View solution in original post

Replies 3 (3)
ShopDoctors
Excursionist
31 2 1

Just wondering if there's any plan to address this issue?

ShopDoctors
Excursionist
31 2 1

I'm guessing this could be improved once Shipping Zones become available in the GraphQL API? Any plan to improve add weight_unit to the rates before that?

ShopDoctors
Excursionist
31 2 1

This is an accepted solution.

I figured it out... Shipping Zones are already available in GraphQl, however they are named Delivery Profile: 

https://shopify.dev/api/admin/graphql/reference/shipping-and-fulfillment/deliveryprofile

Using GraphQl you can get the shipping zones setup with the necessary weight units and currency codes, both of which can be inconsistent between different rates.

Example:

{
  deliveryProfiles(first:1) {
    edges {
      node {
        profileLocationGroups {
          locationGroupZones(first:10) {
            edges {
              node {
                methodDefinitions(first:10, eligible: true) {
                  edges {
                    node {
                      active
                      name
                      methodConditions {
                        field
                        operator
                        conditionCriteria {
                          __typename
                          ... on Weight {
                            value
                            unit
                          }
                          ... on MoneyV2 {
                            amount
                            currencyCode
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}