Skip to main content
Version: 1.0.0

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

ArgumentTypeRequiredDescription
cartIdStringYesThe unique identifier of the cart to set the shipping address on. This ID is obtained from createGuestCart or createCustomerCart mutations.
addressShippingAddressInputYesThe shipping address information to set on the cart.

ShippingAddressInput

FieldTypeRequiredDescription
firstnameStringYesFirst name of the shipping contact.
lastnameStringYesLast name of the shipping contact.
telephoneStringYesPhone number of the shipping contact.
streetStringYesStreet address for shipping.
cityStringYesCity for shipping.
postcodeStringYesPostal or ZIP code for shipping.
country_codeStringYesTwo-letter country code for shipping (e.g., "US", "GB", "DE").
companyStringNoCompany name, if applicable.
identification_numberStringNoBusiness identification number, if applicable.
tax_identification_numberStringNoTax identification number, if applicable.

Return Values

The mutation returns a CheckoutType object with the following fields:

FieldTypeDescription
emailStringThe email address associated with the checkout, if set. Will be null if not set.
shipping_addressObjectThe 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 setBillingAddressOnCheckout mutation with the same_as_shipping parameter set to true, or you can call setBillingAddressOnCheckout first with the same_as_shipping parameter 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").