SetBillingAddressOnCheckoutMutation
Description
Sets the billing address on the checkout/cart. This mutation is a required step in the checkout process before placing an order.
Endpoint
mutation setBillingAddressOnCheckout($cartId: String!, $address: BillingAddressInput!) {
setBillingAddressOnCheckout(cartId: $cartId, address: $address) {
# Return fields
}
}
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
| cartId | String | Yes | The unique identifier of the cart to set the billing address on. This ID is obtained from createGuestCart or createCustomerCart mutations. |
| address | BillingAddressInput | Yes | The billing address information to set on the cart. |
BillingAddressInput
| Field | Type | Required | Description |
|---|---|---|---|
| firstname | String | Yes | First name of the billing contact. |
| lastname | String | Yes | Last name of the billing contact. |
| telephone | String | Yes | Phone number of the billing contact. |
| street | String | Yes | Street address for billing. |
| city | String | Yes | City for billing. |
| postcode | String | Yes | Postal or ZIP code for billing. |
| country_code | String | Yes | Two-letter country code for billing (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. |
| same_as_shipping | Boolean | No | If set to true, the billing address will also be used as the shipping address. |
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. | |
| billing_address | Object | The billing address that was set on the cart. |
| shipping_address | Object | The shipping address on the cart. Only returned if same_as_shipping was set to true. |
Usage Example
mutation {
setBillingAddressOnCheckout(
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",
same_as_shipping: true
}
) {
email
billing_address {
firstname
lastname
street
city
postcode
country_code
}
shipping_address {
firstname
lastname
street
city
postcode
country_code
}
}
}
Example Response
{
"data": {
"setBillingAddressOnCheckout": {
"email": null,
"billing_address": {
"firstname": "John",
"lastname": "Doe",
"street": "123 Main St",
"city": "Anytown",
"postcode": "12345",
"country_code": "US"
},
"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
same_as_shippingis set to true, the billing address will also be used as the shipping address, overriding any previously set shipping address. - If
same_as_shippingis not set or is false, you must also callsetShippingAddressOnCheckoutto set the shipping address. - 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").