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

Commit b3c7efb

Browse files
authored
Draft: Reorg GraphQL quote topic (#4502)
* checkpoint * fix broken links * one mutation per topic * Add consistency between topics * Apply suggestions from code review Co-Authored-By: Erik Marr <[email protected]> * incorporate review comments
1 parent 7ab9994 commit b3c7efb

20 files changed

+1961
-499
lines changed

_data/toc/graphql.yml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,48 @@ pages:
8686
- label: GroupedProduct endpoint
8787
url: /graphql/reference/grouped-product.html
8888

89-
- label: Quote endpoint
89+
- label: Quote endpoint (cart query)
9090
url: /graphql/reference/quote.html
91+
children:
92+
93+
- label: addSimpleProductsToCart mutation
94+
url: /graphql/reference/quote-add-simple-products.html
95+
96+
- label: addVirtualProductsToCart mutation
97+
url: /graphql/reference/quote-add-virtual-products.html
98+
99+
- label: applyCouponToCart mutation
100+
url: /graphql/reference/quote-apply-coupon.html
101+
102+
- label: createEmptyCart mutation
103+
url: /graphql/reference/quote-create-cart.html
104+
105+
- label: placeOrder mutation
106+
url: /graphql/reference/quote-place-order.html
107+
108+
- label: removeCouponFromCart mutation
109+
url: /graphql/reference/quote-remove-coupon.html
110+
111+
- label: removeItemFromCart mutation
112+
url: /graphql/reference/quote-remove-item.html
113+
114+
- label: setBillingAddressesOnCart mutation
115+
url: /graphql/reference/quote-set-billing-address.html
116+
117+
- label: setGuestEmailOnCart mutation
118+
url: /graphql/reference/quote-set-guest-email.html
119+
120+
- label: setPaymentMethodOnCart mutation
121+
url: /graphql/reference/quote-payment-method.html
122+
123+
- label: setShippingAddressesOnCart mutation
124+
url: /graphql/reference/quote-set-shipping-address.html
125+
126+
- label: setShippingMethodsOnCart mutation
127+
url: /graphql/reference/quote-shipping-method.html
128+
129+
- label: updateCartItems mutation
130+
url: /graphql/reference/quote-update-cart-items.html
91131

92132
- label: Sales endpoint
93133
url: /graphql/reference/sales.html
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Attribute | Data Type | Description
2+
--- | --- | ---
3+
`city` | String! | The city specified for the billing or shipping address
4+
`company` | String | The company specified for the billing or shipping address
5+
`country_code` | String! | The country code and label for the billing or shipping address
6+
`firstname` | String! | The customer's first name
7+
`lastname` | String! | The customer's last name
8+
`postcode` | String | The postal code for the billing or shipping address
9+
`region` | String | The region code and label for the billing or shipping address
10+
`save_in_address_book` | Boolean! | Specifies whether to save the address (`True`/`False`)
11+
`street` | [String]! | An array containing the street for the billing or shipping address
12+
`telephone` | String | The telephone number for the billing or shipping address

_includes/graphql/cart-item-input.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Attribute | Data Type | Description
2+
--- | --- | ---
3+
`quantity` | Float! | The quantity of the item to add to the cart
4+
`sku` | String! | The sku of the product to be added to the cart

_includes/graphql/cart-object.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Attribute | Data Type | Description
2+
--- | --- | ---
3+
`applied_coupon` | [`AppliedCoupon`][AppliedCoupon] | The `AppliedCoupon` object contains the `code` text attribute, which specifies the coupon code
4+
`available_payment_methods` | [AvailablePaymentMethod][AvailablePaymentMethod] | Available payment methods
5+
`billing_address` | [BillingCartAddress][BillingCartAddress] | Contains the billing address specified in the customer's cart
6+
`email` | String | The customer's email address
7+
`items` | [CartItemInterface][CartItemInterface] | Contains the items in the customer's cart
8+
`prices` | [CartPrices][CartPrices] | Contains subtotals and totals
9+
`selected_payment_method` | [SelectedPaymentMethod][SelectedPaymentMethod] | Selected payment method
10+
`shipping_addresses` | [ShippingCartAddress][ShippingCartAddress] | Contains one or more shipping addresses
11+
12+
[AppliedCoupon]: {{page.baseurl}}/graphql/reference/quote.html#AppliedCoupon
13+
[AvailablePaymentMethod]: {{page.baseurl}}/graphql/reference/quote.html#AvailablePaymentMethod
14+
[BillingCartAddress]: {{page.baseurl}}/graphql/reference/quote.html#BillingCartAddress
15+
[CartItemInterface]: {{page.baseurl}}/graphql/reference/quote.html#CartItemInterface
16+
[CartPrices]: {{page.baseurl}}/graphql/reference/quote.html#CartPrices
17+
[SelectedPaymentMethod]: {{page.baseurl}}/graphql/reference/quote.html#SelectedPaymentMethod
18+
[ShippingCartAddress]: {{page.baseurl}}/graphql/reference/quote.html#ShippingCartAddress
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Attribute | Data Type | Description
2+
--- | --- | ---
3+
`id` | Int! | A unique ID assigned to the customizable option
4+
`value_string` | String! | A value assigned to the the customizable option

guides/v2.3/graphql/reference/configurable-product.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ Attribute | Type | Description
720720

721721

722722
### Example usage
723-
The following example adds two black Teton Pullover Hoodies size extra-small to the specified shopping cart. The `cart_id` used in this example was [generated]({{ page.baseurl }}/graphql/reference/quote.html#createEmptyCart) by creating an empty cart.
723+
The following example adds two black Teton Pullover Hoodies size extra-small to the specified shopping cart. The `cart_id` used in this example was [generated]({{ page.baseurl }}/graphql/reference/quote-create-cart.html) by creating an empty cart.
724724

725725
**Request**
726726

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
---
2+
group: graphql
3+
title: addSimpleProductsToCart mutation
4+
---
5+
6+
Simple products are physical products that do not have variations, such as color, size, or price. The `addSimpleProductsToCart` mutation allows you to add multiple simple products to the cart at the same time, but you cannot add other product types with this mutation. To add a simple product to a cart, you must provide the cart ID, the SKU, and the quantity. You can also optionally provide customizable options.
7+
8+
{:.bs-callout .bs-callout-info}
9+
The mutation for [adding configurable products]({{page.baseurl}}/graphql/reference/configurable-product.html) is defined in the `ConfigurableProductGraphQl` module.
10+
11+
## Syntax
12+
13+
`mutation: {addSimpleProductsToCart(input: AddSimpleProductsToCartInput): {AddSimpleProductsToCartOutput}}`
14+
15+
## Example usage
16+
17+
These examples show the minimal payload and a payload that includes customizable options.
18+
19+
### Add a simple product to a cart
20+
21+
The following example adds a simple product to a cart. The response contains the entire contents of the customer's cart.
22+
23+
**Request**
24+
25+
```text
26+
mutation {
27+
addSimpleProductsToCart(
28+
input: {
29+
cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG",
30+
cart_items: [
31+
{
32+
data: {
33+
quantity: 1
34+
sku: "24-MB04"
35+
}
36+
}
37+
]
38+
}
39+
) {
40+
cart {
41+
items {
42+
id
43+
product {
44+
name
45+
sku
46+
}
47+
quantity
48+
}
49+
}
50+
}
51+
}
52+
```
53+
54+
**Response**
55+
56+
```json
57+
{
58+
"data": {
59+
"addSimpleProductsToCart": {
60+
"cart": {
61+
"items": [
62+
{
63+
"id": "13",
64+
"product": {
65+
"name": "Strive Shoulder Pack",
66+
"sku": "24-MB04"
67+
},
68+
"quantity": 1
69+
}
70+
]
71+
}
72+
}
73+
}
74+
}
75+
```
76+
77+
### Add a simple product with customizable options to a cart
78+
79+
If a product has a customizable option, you can specify the option's value in the `addSimpleProductsToCart` request.
80+
81+
**Request**
82+
83+
``` text
84+
mutation {
85+
addSimpleProductsToCart (input: {
86+
cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG",
87+
cart_items: {
88+
data: {
89+
sku: "simple"
90+
quantity: 1
91+
},
92+
customizable_options: [
93+
{
94+
id: 121
95+
value_string: "field value"
96+
}
97+
]
98+
}
99+
}) {
100+
cart {
101+
items {
102+
product {
103+
name
104+
}
105+
quantity
106+
... on SimpleCartItem {
107+
customizable_options {
108+
label
109+
values {
110+
value
111+
}
112+
}
113+
}
114+
}
115+
}
116+
}
117+
}
118+
```
119+
120+
**Response**
121+
122+
```text
123+
{
124+
"data": {
125+
"addSimpleProductsToCart": {
126+
"cart": {
127+
"items": [
128+
{
129+
"product": {
130+
"name": "simple"
131+
},
132+
"quantity": 1,
133+
"customizable_options": [
134+
{
135+
"label": "Field Option",
136+
"values": [
137+
{
138+
"value": "field value"
139+
}
140+
]
141+
}
142+
]
143+
}
144+
]
145+
}
146+
}
147+
}
148+
}
149+
```
150+
151+
## Input attributes
152+
153+
The top-level `AddSimpleProductsToCartInput` object is listed first. All child objects are listed in alphabetical order.
154+
155+
### AddSimpleProductsToCartInput object {#AddSimpleProductsToCartInput}
156+
157+
The `AddSimpleProductsToCartInput` object must contain the following attributes:
158+
159+
Attribute | Data Type | Description
160+
--- | --- | ---
161+
`cart_id` | String! | The unique ID that identifies the customer's cart
162+
`cart_items` | [SimpleProductCartItemInput!](#SimpleProductCartItemInput) | Contains the cart item IDs and quantity of each item
163+
164+
### CartItemInput object {#CartItemInputSimple}
165+
166+
The `CartItemInput` object must contain the following attributes:
167+
168+
{% include graphql/customizable-option-input.md %}
169+
170+
### CustomizableOptionInput object {#CustomizableOptionInputSimple}
171+
172+
The `CustomizableOptionInput` object must contain the following attributes:
173+
174+
{% include graphql/customizable-option-input.md %}
175+
176+
### SimpleProductCartItemInput object {#SimpleProductCartItemInput}
177+
178+
The `SimpleProductCartItemInput` object must contain the following attributes:
179+
180+
`customizable_options` |[[CustomizableOptionInputSimple]](#CustomizableOptionInputSimple) | An array that defines customizable options for the product
181+
`data` | [CartItemInput!](#CartItemInputSimple) | An object containing the `sku` and `quantity` of the product.
182+
183+
## Output attributes
184+
185+
The `AddSimpleProductsToCartOutput` object contains the `Cart` object.
186+
187+
Attribute | Data Type | Description
188+
--- | --- | ---
189+
`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart
190+
191+
### Cart object {#CartObject}
192+
193+
{% include graphql/cart-object.md %}
194+
195+
[Cart query output]({{page.baseurl}}/graphql/reference/quote.html#cart-output) provides more information about the `Cart` object.

0 commit comments

Comments
 (0)