Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit a4d076a

Browse files
authored
Merge pull request #4316 from rogyar/customizable-opts-example-graphql
[GraphQl] Example of using customizable options on add to cart request
2 parents 526a662 + 5895a57 commit a4d076a

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

guides/v2.3/graphql/reference/quote.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,82 @@ mutation {
215215
}
216216
```
217217

218+
### Adding simple product with customizable options to a cart
219+
220+
If a product has a customizable option, the option's value can be specified in the add to cart request.
221+
222+
**Request**
223+
224+
``` text
225+
mutation {
226+
addSimpleProductsToCart (input: {
227+
cart_id: "nu31JXR9DaqbdVqFDGnqjrMJmUnT3mzB"
228+
cartItems: {
229+
data: {
230+
sku:"simple"
231+
qty:1
232+
},
233+
customizable_options: [
234+
{
235+
id: 121
236+
value: "field value"
237+
}
238+
]
239+
}
240+
}) {
241+
cart {
242+
items {
243+
product {
244+
name
245+
}
246+
qty
247+
248+
... on SimpleCartItem {
249+
customizable_options {
250+
label
251+
values {
252+
value
253+
}
254+
}
255+
}
256+
}
257+
}
258+
}
259+
}
260+
```
261+
262+
**Response**
263+
264+
```text
265+
{
266+
"data": {
267+
"addSimpleProductsToCart": {
268+
"cart": {
269+
"items": [
270+
{
271+
"product": {
272+
"name": "simple"
273+
},
274+
"qty": 2,
275+
"customizable_options": [
276+
{
277+
"label": "Field Option",
278+
"values": [
279+
{
280+
"value": "field value"
281+
}
282+
]
283+
}
284+
]
285+
}
286+
]
287+
}
288+
}
289+
}
290+
}
291+
```
292+
293+
218294
### Updating billing and shipping information
219295
{:.no_toc}
220296

0 commit comments

Comments
 (0)