SetShippingAddressOnCheckoutMutation
Description
Sets the shipping address on the checkout/cart. This mutation is a required step in the checkout process before placing an order.
Endpoint
mutation setShippingAddressOnCheckout($cartId: String!, $address: ShippingAddressInput!) {
setShippingAddressOnCheckout(cartId: $cartId, address: $address) {
# Return fields
}
}
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
| cartId | String | Yes | The unique identifier of the cart to set the shipping address on. This ID is obtained from createGuestCart or createCustomerCart mutations. |
| address | ShippingAddressInput | Yes | The shipping address information to set on the cart. |
ShippingAddressInput
| Field | Type | Required | Description |
|---|---|---|---|
| firstname | String | Yes | First name of the shipping contact. |
| lastname | String | Yes | Last name of the shipping contact. |
| telephone | String | Yes | Phone number of the shipping contact. |
| street | String | Yes | Street address for shipping. |
| city | String | Yes | City for shipping. |
| postcode | String | Yes | Postal or ZIP code for shipping. |
| country_code | String | Yes | Two-letter country code for shipping (e.g., "US", "GB", "DE"). |
| company | String | No | Company name, if applicable. |
| identification_number | String | No | Business identification number, if applicable. |
| tax_identification_number | String | No | Tax identification number, if applicable. |
Return Values
The mutation returns a CheckoutType object with the following fields:
| Field | Type | Description |
|---|---|---|
| String | The email address associated with the checkout, if set. Will be null if not set. | |
| shipping_address | Object | The shipping address that was set on the cart. |
Usage Example
mutation {
setShippingAddressOnCheckout(
cartId: "abc123",
address: {
firstname: "John",
lastname: "Doe",
telephone: "555-123-4567",
street: "123 Main St",
city: "Anytown",
postcode: "12345",
country_code: "US",
company: "ACME Corp"
}
) {
email
shipping_address {
firstname
lastname
street
city
postcode
country_code
}
}
}
Example Response
{
"data": {
"setShippingAddressOnCheckout": {
"email": null,
"shipping_address": {
"firstname": "John",
"lastname": "Doe",
"street": "123 Main St",
"city": "Anytown",
"postcode": "12345",
"country_code": "US"
}
}
}
}
Notes
- This mutation must be called before attempting to place an order.
- If you want to use the same address for both shipping and billing, you can either call this mutation first and then use the
setBillingAddressOnCheckoutmutation with thesame_as_shippingparameter set to true, or you can callsetBillingAddressOnCheckoutfirst with thesame_as_shippingparameter set to true. - If the address information is invalid or incomplete, an error will be thrown with a descriptive message.
- The country code must be a valid two-letter ISO country code (e.g., "US", "GB", "DE").