setBillingAddressOnCart mutation

The setBillingAddressOnCart mutation sets the billing address for a specific cart. If you set the use_for_shipping attribute to true, Magento assigns the same address as the shipping address.

Syntax

mutation: {setBillingAddressOnCart(input: SetBillingAddressOnCartInput) {SetBillingAddressOnCartOutput}}

Example usage

The following example creates a new billing address for a specific cart.

Request

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
mutation {
  setBillingAddressOnCart(
    input: {
      cart_id: "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C"
      billing_address: {
        address: {
          firstname: "Bob"
          lastname: "Roll"
          company: "Magento"
          street: ["Magento Pkwy", "Main Street"]
          city: "Austin"
          region: "TX"
          postcode: "78758"
          country_code: "US"
          telephone: "8675309"
          save_in_address_book: true
        }
        use_for_shipping: false
      }
    }
  ) {
    cart {
      billing_address {
        firstname
        lastname
        company
        street
        city
        postcode
        telephone
      }
    }
  }
}

Response

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
  "data": {
    "setBillingAddressOnCart": {
      "cart": {
        "billing_address": {
          "firstname": "Bob",
          "lastname": "Roll",
          "company": "Magento",
          "street": [
            "Magento Pkwy",
            "Main Street"
          ],
          "city": "Austin",
          "postcode": "78758",
          "telephone": "8675309"
        }
      }
    }
  }
}

Input attributes

The top-level SetBillingAddressOnCartInput object is listed first. All child objects are listed in alphabetical order.

SetBillingAddressOnCartInput object

Attribute Data Type Description
billing_address BillingAddressInput! The billing address for a specific cart
cart_id String! The unique ID that identifies the customer’s cart

BillingAddressInput object

Attribute Data Type Description
address CartAddressInput The billing address for the cart
customer_address_id Int The unique ID that identifies the customer’s address
use_for_shipping Boolean Specifies whether to use the billing address for the shipping address (True/False)

CartAddressInput object

Attribute Data Type Description
city String! The city specified for the billing or shipping address
company String The company specified for the billing or shipping address
country_code String! The country code and label for the billing or shipping address
firstname String! The customer’s first name
lastname String! The customer’s last name
postcode String The postal code for the billing or shipping address
region String The region code and label for the billing or shipping address
save_in_address_book Boolean! Specifies whether to save the address (True/False)
street [String]! An array containing the street for the billing or shipping address
telephone String The telephone number for the billing or shipping address

Output attributes

The SetBillingAddressOnCartOutput object contains the Cart object.

Attribute Data Type Description
cart Cart! Describes the contents of the specified shopping cart

Cart object

Attribute Data Type Description
applied_coupon AppliedCoupon The AppliedCoupon object contains the code text attribute, which specifies the coupon code
available_payment_methods AvailablePaymentMethod Available payment methods
billing_address BillingCartAddress Contains the billing address specified in the customer’s cart
email String The customer’s email address
items CartItemInterface Contains the items in the customer’s cart
prices CartPrices Contains subtotals and totals
selected_payment_method SelectedPaymentMethod Selected payment method
shipping_addresses ShippingCartAddress Contains one or more shipping addresses

Cart query output provides more information about the Cart object.