@@ -212,26 +212,41 @@ mutation {
212
212
213
213
### Use the existing customer address
214
214
215
+ Use a query below to retrieve the list of customer addresses:
216
+
215
217
** Request**
218
+
216
219
``` 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
224
226
}
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
+ ]
230
243
}
231
244
}
232
245
}
233
246
```
234
247
248
+ Define ` customer_address_id ` to assign the existing customer address.
249
+
235
250
** Request**
236
251
237
252
``` text
@@ -240,19 +255,7 @@ mutation {
240
255
input: {
241
256
cart_id: "{{ CART_ID }}"
242
257
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 }}
256
259
}
257
260
}
258
261
) {
@@ -271,26 +274,17 @@ mutation {
271
274
}
272
275
address_type
273
276
}
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
- }
288
277
}
289
278
}
290
279
}
291
280
```
292
281
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
+
293
286
** Response**
287
+
294
288
``` json
295
289
{
296
290
"data" : {
@@ -312,26 +306,7 @@ mutation {
312
306
"label" : " US"
313
307
},
314
308
"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
+ }
335
310
}
336
311
}
337
312
}
0 commit comments