Step 5. Set billing address
You must always set the billing address to place an order.
Use the setBillingAddressOnCart mutation to set a billing address.
Add a billing address to the cart
Similar to the shipping address, add a billing address to the cart. { CART_ID }
is the unique shopping cart ID from Step 2. Create empty cart. The street address is also different, so we can see that different addresses are being created.
Send the customer's authorization token in the Authorization
parameter of the header. See Authorization tokens for more information.
Request:
Copied to your clipboardmutation {setBillingAddressOnCart(input: {cart_id: "{ CART_ID }"billing_address: {address: {firstname: "John"lastname: "Doe"company: "Company Name"street: ["64 Strawberry Dr", "Beverly Hills"]city: "Los Angeles"region: "CA"region_id: 12postcode: "90210"country_code: "US"telephone: "123-456-0000"save_in_address_book: true}}}) {cart {billing_address {firstnamelastnamecompanystreetcityregion{codelabel}postcodetelephonecountry {codelabel}}}}}
Response:
Copied to your clipboard{"data": {"setBillingAddressOnCart": {"cart": {"billing_address": {"firstname": "John","lastname": "Doe","company": "Company Name","street": ["64 Strawberry Dr","Beverly Hills"],"city": "Los Angeles","region": {"code": "CA","label": "California"},"postcode": "90210","telephone": "123-456-0000","country": {"code": "US","label": "US"}}}}}}
Verify this step
Sign in as a customer to the website using the email
john.doe@example.com
and passwordb1b2b3l@w+
.Go to Checkout.
Go to the Review & Payments step. The Billing Address form is populated with the address details you entered.