PHP 7.3 reached end of support in December 2021 and Adobe Commerce 2.3.x reaches end of support in September 2022. You may want to consider planning your upgrade now to Adobe Commerce 2.4.x and PHP 7.4.x to help maintain PCI compliance.
Step 6. Set the shipping method
GraphQL checkout tutorial
The setShippingMethodsOnCart
mutation defines the shipping methods for your order. It requires these input parameters:
cart_id
carrier_code
method_code
{ CART_ID }
is the unique shopping cart ID from Step 2. Create empty cart.
For logged-in customers, send the customer’s authorization token in the Authorization
parameter of the header. See Authorization tokens for more information.
Request:
The following mutation query assigns UPS “Ground” method.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
mutation {
setShippingMethodsOnCart(input: {
cart_id: "{ CART_ID }"
shipping_methods: [
{
carrier_code: "ups"
method_code: "GND"
}
]
}) {
cart {
shipping_addresses {
selected_shipping_method {
carrier_code
method_code
carrier_title
method_title
}
}
}
}
}
Response:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
"data": {
"setShippingMethodsOnCart": {
"cart": {
"shipping_addresses": [
{
"selected_shipping_method": {
"carrier_code": "ups",
"method_code": "GND",
"carrier_title": "United Parcel Service",
"method_title": "Ground"
}
}
]
}
}
}
}
Verify this step
-
Sign in as a customer to the website using the email
john.doe@example.com
and passwordb1b2b3l@w+
. -
Go to Checkout.
-
The selected shipping method is displayed in the Shipping Methods section on the Shipping step.