Set Shipping Method
Set the shipping method for a cart.
Authentication
This query supports both authenticated customers and guest users:
- Authenticated customers: Provide a valid customer authentication token in the
Authorizationheader. Obtain this token via the Customer Login API. - Guest users: Provide the Guest Cart Token
cartTokenobtained from the Create Cart mutation.
Authorization: Bearer <accessToken>Arguments
| Name | Type | Required | Description |
|---|---|---|---|
shippingMethod | String | ✅ Yes | Shipping method code (e.g., flatrate_flatrate) |
Response
| Field | Type | Description |
|---|---|---|
success | Boolean | Success status |
id | String | Shipping method ID |
message | String | Success or error message |
Common Shipping Method Codes
| Code | Description |
|---|---|
flatrate_flatrate | Flat Rate - Fixed shipping cost |
free_free | Free Shipping - No shipping charge |
Prerequisites
- Shipping address must be set before this mutation
- Available shipping methods depend on:
- Cart items
- Shipping address country/region
- Store configuration
Validation Rules
- Shipping method code must be valid and available
- Shipping address must be set
- Cart must have items
Error Responses
json
{
"errors": {
"shippingMethod": ["Invalid or unavailable shipping method."],
"shippingAddress": ["Shipping address must be set first."]
}
}
