Skip to main content
Version: 2.0.0

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

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

BillingAddressInput

FieldTypeRequiredDescription
firstnameStringYesFirst name of the billing contact.
lastnameStringYesLast name of the billing contact.
telephoneStringYesPhone number of the billing contact.
streetStringYesStreet address for billing.
cityStringYesCity for billing.
postcodeStringYesPostal or ZIP code for billing.
country_codeStringYesTwo-letter country code for billing (e.g., "US", "GB", "DE").
companyStringNoCompany name, if applicable.
identification_numberStringNoBusiness identification number, if applicable.
tax_identification_numberStringNoTax identification number, if applicable.
same_as_shippingBooleanNoIf 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:

FieldTypeDescription
emailStringThe email address associated with the checkout, if set. Will be null if not set.
billing_addressObjectThe billing address that was set on the cart.
shipping_addressObjectThe 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_shipping is set to true, the billing address will also be used as the shipping address, overriding any previously set shipping address.
  • If same_as_shipping is not set or is false, you must also call setShippingAddressOnCheckout to 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").