Update delivery method on a subscription contract
Changes how a subscription is delivered, to a live rate or to one of the store’s delivery methods.
A live rate (carrier-rate=true): send a rate from List live carrier-quoted shipping rates for a subscription contract: its name as delivery-method-title and delivery-method-presentment-title, and its code as delivery-method-code, exactly as returned. Appstle asks Shopify to quote the subscription again and applies the rate with that title and code at the price Shopify quotes now. delivery-method-id is ignored. Applying the rate the subscription already has returns 204 and leaves its delivery method and price as they are. Applying a rate turns off Use Custom Delivery Price on the subscription.
A delivery method (carrier-rate left out): send the id of a method from Get delivery options for subscription contract as delivery-method-id. The subscription takes the method’s name and, for a fixed rate, its price. A carrier-calculated method keeps the subscription’s current price, so apply a live rate for those instead. The call turns on Use Custom Delivery Price, so Appstle stops updating the subscription’s shipping price. On a store that uses Shopify Markets shipping, Appstle applies the method at the price Shopify quotes now and turns Use Custom Delivery Price off instead.
The call returns 400 and changes nothing when:
- The rate is no longer quoted: with
carrier-rate=true, Shopify’s new quote has no rate with that title and code. A differentcodefor the same title counts as a different rate. List the rates again - Shopify can’t quote the subscription: the message is
UserGeneratedError:Unable to retrieve delivery details from Shopify. - The method isn’t offered to the customer: Get delivery options doesn’t return that
delivery-method-idfor this subscription. The error key isshippingOptionUnavailable - Customers can’t change their delivery method:
enableUpdateDeliveryMethodisfalsein the customer portal settings. New stores start with itfalse - The subscription is locked until its minimum cycles:
freezeOrderTillMinCycleistrueand the subscription hasn’t reached its minimum number of billing cycles, or a line’s_min-cyclesminimum hasn’t been reached. The message is the store’s own - The contract isn’t the customer’s: the error key is
invalidContract - It’s a gift subscription: the buyer can’t change it. The error key is
giftBuyerReadOnly
When message starts with UserGeneratedError:, the text after it is written for the customer: show it, and don’t match on its wording.
Authentication: Customer must be logged in via Shopify customer session
curl --request PUT \
--url https://www.myshop.com/apps/subscriptions/cp/api/subscription-contracts-update-delivery-methodimport requests
url = "https://www.myshop.com/apps/subscriptions/cp/api/subscription-contracts-update-delivery-method"
response = requests.put(url)
print(response.text)const options = {method: 'PUT'};
fetch('https://www.myshop.com/apps/subscriptions/cp/api/subscription-contracts-update-delivery-method', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://www.myshop.com/apps/subscriptions/cp/api/subscription-contracts-update-delivery-method';
const options = {method: 'PUT'};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.myshop.com/apps/subscriptions/cp/api/subscription-contracts-update-delivery-method",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://www.myshop.com/apps/subscriptions/cp/api/subscription-contracts-update-delivery-method"
req, _ := http.NewRequest("PUT", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://www.myshop.com/apps/subscriptions/cp/api/subscription-contracts-update-delivery-method")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
response = http.request(request)
puts response.read_body{
"message": "UserGeneratedError:The selected shipping rate is no longer available from the carrier. Please refresh the available rates and choose again.",
"params": "",
"status": 400,
"title": "UserGeneratedError:The selected shipping rate is no longer available from the carrier. Please refresh the available rates and choose again.",
"type": "https://appstle.com/problem/problem-with-message"
}Query Parameters
Response
The delivery method was applied, or the subscription already had it. The body is empty.
curl --request PUT \
--url https://www.myshop.com/apps/subscriptions/cp/api/subscription-contracts-update-delivery-methodimport requests
url = "https://www.myshop.com/apps/subscriptions/cp/api/subscription-contracts-update-delivery-method"
response = requests.put(url)
print(response.text)const options = {method: 'PUT'};
fetch('https://www.myshop.com/apps/subscriptions/cp/api/subscription-contracts-update-delivery-method', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://www.myshop.com/apps/subscriptions/cp/api/subscription-contracts-update-delivery-method';
const options = {method: 'PUT'};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.myshop.com/apps/subscriptions/cp/api/subscription-contracts-update-delivery-method",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://www.myshop.com/apps/subscriptions/cp/api/subscription-contracts-update-delivery-method"
req, _ := http.NewRequest("PUT", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://www.myshop.com/apps/subscriptions/cp/api/subscription-contracts-update-delivery-method")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
response = http.request(request)
puts response.read_body{
"message": "UserGeneratedError:The selected shipping rate is no longer available from the carrier. Please refresh the available rates and choose again.",
"params": "",
"status": 400,
"title": "UserGeneratedError:The selected shipping rate is no longer available from the carrier. Please refresh the available rates and choose again.",
"type": "https://appstle.com/problem/problem-with-message"
}