PHP 7.3 reached end of support in December 2021 and Adobe Commerce 2.3.x reaches end of support in September 2022. You may want to consider planning your upgrade now to Adobe Commerce 2.4.x and PHP 7.4.x to help maintain PCI compliance.
setBillingAddressOnCart mutation
The setBillingAddressOnCart
mutation sets the billing address for a specific cart. If you set the same_as_shipping
attribute to true
, Magento assigns the same address as the shipping address.
Syntax
1
2
3
4
5
6
7
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
35
36
37
38
39
40
41
42
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
}
same_as_shipping: false
}
}
) {
cart {
billing_address {
firstname
lastname
company
street
city
region{
code
label
}
postcode
telephone
country{
code
label
}
}
}
}
}
Response:
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
{
"data": {
"setBillingAddressOnCart": {
"cart": {
"billing_address": {
"firstname": "Bob",
"lastname": "Roll",
"company": "Magento",
"street": [
"Magento Pkwy",
"Main Street"
],
"city": "Austin",
"region": {
"code": "TX",
"label": "Texas"
},
"postcode": "78758",
"telephone": "8675309",
"country": {
"code": "US",
"label": "US"
}
}
}
}
}
}
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 |
same_as_shipping |
Boolean | Specifies whether to use the shipping address for the billing address |
use_for_shipping |
Boolean | Deprecated. Use same_as_shipping instead |
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 |
Deprecated. Use applied_coupons instead |
applied_coupons |
[AppliedCoupon ] |
An array of AppliedCoupon objects. Each object contains the code text attribute, which specifies the coupon code |
applied_gift_cards |
[AppliedGiftCard ] |
An array of AppliedGiftCard objects. An AppliedGiftCard object contains the code text attribute, which specifies the gift card code. applied_gift_cards is a Commerce-only attribute, defined in the GiftCardAccountGraphQl module |
applied_store_credit |
AppliedStoreCredit |
Contains store credit information applied to the cart. applied_store_credit is a Commerce-only attribute, defined in the CustomerBalanceGraphQl module |
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 |
id |
ID! | The ID of the cart |
is_virtual |
Boolean! | Indicates whether the cart contains only virtual products |
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 |
total_quantity |
Float! | Total Quantity of products in the cart |
Cart query output provides more information about the Cart
object.