Skip to content

Commit 65bdfa5

Browse files
committed
magento#589: Add a tutorial for the checkout workflow
1 parent bac65d8 commit 65bdfa5

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed

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

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,134 @@ where
107107
}
108108
```
109109

110+
### Use for shipping a defined billing address
111+
112+
See [Add a new address for billing and shipping]({{ page.baseurl }}/graphql/tutorials/checkout/checkout-billing-address.html) topic.
113+
110114
{:.bs-callout .bs-callout-info}
111115
Send customer's authorization token in the `Authorization` parameter of the header if you set shipping address for a registered customer. See ["Get customer authorization token"]({{ page.baseurl }}/graphql/get-customer-authorization-token.html) to get more details.
116+
117+
### Use the existing customer's address
118+
119+
Use a query below to retrieve the list of customer addresses:
120+
121+
**Request**
122+
123+
```text
124+
query {
125+
customer {
126+
addresses {
127+
id
128+
default_billing
129+
default_shipping
130+
}
131+
}
132+
}
133+
```
134+
135+
**Response**
136+
137+
```text
138+
{
139+
"data": {
140+
"customer": {
141+
"addresses": [
142+
{
143+
"id": 2,
144+
"default_billing": true,
145+
"default_shipping": false
146+
},
147+
{
148+
"id": 3,
149+
"default_billing": false,
150+
"default_shipping": false
151+
},
152+
{
153+
"id": 4,
154+
"default_billing": false,
155+
"default_shipping": true
156+
}
157+
]
158+
}
159+
}
160+
}
161+
```
162+
163+
Define `customer_address_id` to assign the existing customer address.
164+
165+
**Request**
166+
167+
```text
168+
mutation {
169+
setShippingAddressesOnCart(
170+
input: {
171+
cart_id: "{{ CART_ID }}"
172+
shipping_addresses: {
173+
customer_address_id: {{ CUSTOMER_ADDRESS_ID }}
174+
}
175+
}
176+
) {
177+
cart {
178+
shipping_addresses {
179+
firstname
180+
lastname
181+
company
182+
street
183+
city
184+
region {
185+
code
186+
label
187+
}
188+
postcode
189+
telephone
190+
country
191+
{
192+
code
193+
label
194+
}
195+
address_type
196+
}
197+
}
198+
}
199+
}
200+
```
201+
202+
where
203+
`{{ CART_ID }}` - shopping cart unique ID from [Step 2. Create empty cart]({{ page.baseurl }}/graphql/tutorials/checkout/checkout-add-product-to-cart.html).
204+
`{{ CUSTOMER_ADDRESS_ID }}` - customer address ID (value from `entity_id` field of `customer_address_entity` table).
205+
206+
**Response**
207+
208+
```json
209+
{
210+
"data": {
211+
"setShippingAddressesOnCart": {
212+
"cart": {
213+
"shipping_addresses": [
214+
{
215+
"firstname": "John",
216+
"lastname": "Doe",
217+
"company": "Company Name",
218+
"street": [
219+
"320 N Crescent Dr",
220+
"Beverly Hills"
221+
],
222+
"city": "Los Angeles",
223+
"region": {
224+
"code": "CA",
225+
"label": "California"
226+
},
227+
"postcode": "90210",
228+
"telephone": "123-456-0000",
229+
"country": {
230+
"code": "US",
231+
"label": "US"
232+
},
233+
"address_type": "SHIPPING"
234+
}
235+
]
236+
}
237+
}
238+
}
239+
}
240+
```

0 commit comments

Comments
 (0)