For subscription orders, is there a mutation to get a new shipping rate? For example, the customer changes their address. We’d like Shopify to recompute the rate based on the new address.
Topic summary
A developer is trying to retrieve updated shipping rates for subscription orders when a customer changes their address. They want to force Shopify to recompute rates based on the new address.
Current Approach:
- Using the
shippingOptionsfield on aSubscriptionDraftobject via GraphQL - Passing the new delivery address directly in the query parameters
Issues Encountered:
- The query returns
deliveryPriceas “0.0” shippingOptionsfrequently returns an empty array- The API sometimes fails entirely or returns null responses, especially when there are many line items
- Errors occur intermittently during processing
Recommended Solution:
- Implement a retry mechanism to handle the unreliable API responses
- This is acknowledged as one of the most challenging aspects of Shopify’s subscription APIs
- The retry approach leads to slower processing and UI delays, but is currently necessary
Status: The issue remains unresolved with no definitive workaround beyond implementing retries to handle the API’s inconsistent behavior.
You can always grab the shipping options available on a SubscriptionDraft: https://shopify.dev/api/admin-graphql/2022-04/objects/SubscriptionDraft#field-subscriptiondraft-shippingoptions
That said - you’ll have to implement a retry mechanism bc it fails (or returns an empty array) often and if there are too many lines it fails every time.
Hi, @Brian_S_1 .
Here’s a sample GraphQL query I have. I’m passing in a Draft ID on it and a new address.
query ($id:ID!) {
subscriptionDraft(id: $id) {
deliveryPrice{
amount
}
shippingOptions(
deliveryAddress: {
firstName: "Eric",
lastName: "Test",
address1: "4754 Irving Road",
address2: "",
city: "Athens",
provinceCode: "OH",
countryCode: US,
zip: "45701"
}
) {
__typename
... on SubscriptionShippingOptionResultSuccess {
shippingOptions {
title
presentmentTitle
description
code
price {
amount
currencyCode
}
}
}
}
id
status
}
}
Here’s the response from Postman.
{
"data": {
"subscriptionDraft": {
"deliveryPrice": {
"amount": "0.0"
},
"shippingOptions": {
"__typename": "SubscriptionShippingOptionResultSuccess",
"shippingOptions": []
},
"id": "gid://shopify/SubscriptionDraft/125750378712",
"status": "ACTIVE"
}
},
"extensions": {
"cost": {
"requestedQueryCost": 3,
"actualQueryCost": 3,
"throttleStatus": {
"maximumAvailable": 10000.0,
"currentlyAvailable": 9997,
"restoreRate": 500.0
}
}
}
}
I’m getting a “0.0” delivery price. Is this supposed to recompute the shipping rate?
@Brian_S_1 I get it now. We’re getting shippingOptions but it almost always returns empty array as seen in my snippet above.
That’s right. This is one of the most difficult parts of the subscription apis. There used to be Shopify docs around this stuff but I can’t find them now.
Sometimes the shipping options are empty, null and sometimes we get an error response.. we’ve just found that a retry mechanism is required and it leads to slower processing/UI