Skip to content

Commit 53de037

Browse files
committed
magento#589: Add a tutorial for the checkout workflow
1 parent 4c4d872 commit 53de037

File tree

1 file changed

+34
-59
lines changed

1 file changed

+34
-59
lines changed

guides/v2.3/graphql/tutorials/checkout/checkout-billing-address.md

Lines changed: 34 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -212,26 +212,41 @@ mutation {
212212

213213
### Use the existing customer address
214214

215+
Use a query below to retrieve the list of customer addresses:
216+
215217
**Request**
218+
216219
```text
217-
mutation {
218-
setBillingAddressOnCart(
219-
input: {
220-
cart_id: "{{ CART_ID }}"
221-
billing_address: {
222-
customer_address_id: {{ CUSTOMER_ADDRESS_ID }}
223-
}
220+
query {
221+
customer {
222+
addresses {
223+
id
224+
default_billing
225+
default_shipping
224226
}
225-
) {
226-
cart {
227-
billing_address {
228-
city
229-
}
227+
}
228+
}
229+
```
230+
231+
**Response**
232+
233+
```text
234+
"data": {
235+
"customer": {
236+
"addresses": [
237+
{
238+
"id": 2,
239+
"default_billing": true,
240+
"default_shipping": true
241+
}
242+
]
230243
}
231244
}
232245
}
233246
```
234247

248+
Define `customer_address_id` to assign the existing customer address.
249+
235250
**Request**
236251

237252
```text
@@ -240,19 +255,7 @@ mutation {
240255
input: {
241256
cart_id: "{{ CART_ID }}"
242257
billing_address: {
243-
address: {
244-
firstname: "John"
245-
lastname: "Doe"
246-
company: "Company Name"
247-
street: ["320 N Crescent Dr", "Beverly Hills"]
248-
city: "Los Angeles"
249-
region: "CA"
250-
postcode: "90210"
251-
country_code: "US"
252-
telephone: "123-456-0000"
253-
save_in_address_book: false
254-
}
255-
# use_for_shipping: true
258+
customer_address_id: {{ CUSTOMER_ADDRESS_ID }}
256259
}
257260
}
258261
) {
@@ -271,26 +274,17 @@ mutation {
271274
}
272275
address_type
273276
}
274-
shipping_addresses {
275-
firstname
276-
lastname
277-
company
278-
street
279-
city
280-
postcode
281-
telephone
282-
country {
283-
code
284-
label
285-
}
286-
address_type
287-
}
288277
}
289278
}
290279
}
291280
```
292281

282+
where
283+
`{{ CART_ID }}` - shopping cart unique ID from [Step 2. Create empty cart]({{ page.baseurl }}/graphql/tutorials/checkout/checkout-add-product-to-cart.html).
284+
`{{ CUSTOMER_ADDRESS_ID }}` - customer address ID (value from `entity_id` field of `customer_address_entity` table).
285+
293286
**Response**
287+
294288
```json
295289
{
296290
"data": {
@@ -312,26 +306,7 @@ mutation {
312306
"label": "US"
313307
},
314308
"address_type": "BILLING"
315-
},
316-
"shipping_addresses": [
317-
{
318-
"firstname": "John",
319-
"lastname": "Doe",
320-
"company": "Company Name",
321-
"street": [
322-
"320 N Crescent Dr",
323-
"Beverly Hills"
324-
],
325-
"city": "Los Angeles",
326-
"postcode": "90210",
327-
"telephone": "123-456-0000",
328-
"country": {
329-
"code": "US",
330-
"label": "US"
331-
},
332-
"address_type": "SHIPPING"
333-
}
334-
]
309+
}
335310
}
336311
}
337312
}

0 commit comments

Comments
 (0)