This repository has been archived by the owner on Nov 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <45772211+erikmarr@users.noreply.github.com> * incorporate review comments
- Loading branch information
Showing
20 changed files
with
1,961 additions
and
499 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Attribute | Data Type | Description | ||
--- | --- | --- | ||
`city` | String! | The city specified for the billing or shipping address | ||
`company` | String | The company specified for the billing or shipping address | ||
`country_code` | String! | The country code and label for the billing or shipping address | ||
`firstname` | String! | The customer's first name | ||
`lastname` | String! | The customer's last name | ||
`postcode` | String | The postal code for the billing or shipping address | ||
`region` | String | The region code and label for the billing or shipping address | ||
`save_in_address_book` | Boolean! | Specifies whether to save the address (`True`/`False`) | ||
`street` | [String]! | An array containing the street for the billing or shipping address | ||
`telephone` | String | The telephone number for the billing or shipping address |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Attribute | Data Type | Description | ||
--- | --- | --- | ||
`quantity` | Float! | The quantity of the item to add to the cart | ||
`sku` | String! | The sku of the product to be added to the cart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Attribute | Data Type | Description | ||
--- | --- | --- | ||
`applied_coupon` | [`AppliedCoupon`][AppliedCoupon] | The `AppliedCoupon` object contains the `code` text attribute, which specifies the coupon code | ||
`available_payment_methods` | [AvailablePaymentMethod][AvailablePaymentMethod] | Available payment methods | ||
`billing_address` | [BillingCartAddress][BillingCartAddress] | Contains the billing address specified in the customer's cart | ||
`email` | String | The customer's email address | ||
`items` | [CartItemInterface][CartItemInterface] | Contains the items in the customer's cart | ||
`prices` | [CartPrices][CartPrices] | Contains subtotals and totals | ||
`selected_payment_method` | [SelectedPaymentMethod][SelectedPaymentMethod] | Selected payment method | ||
`shipping_addresses` | [ShippingCartAddress][ShippingCartAddress] | Contains one or more shipping addresses | ||
|
||
[AppliedCoupon]: {{page.baseurl}}/graphql/reference/quote.html#AppliedCoupon | ||
[AvailablePaymentMethod]: {{page.baseurl}}/graphql/reference/quote.html#AvailablePaymentMethod | ||
[BillingCartAddress]: {{page.baseurl}}/graphql/reference/quote.html#BillingCartAddress | ||
[CartItemInterface]: {{page.baseurl}}/graphql/reference/quote.html#CartItemInterface | ||
[CartPrices]: {{page.baseurl}}/graphql/reference/quote.html#CartPrices | ||
[SelectedPaymentMethod]: {{page.baseurl}}/graphql/reference/quote.html#SelectedPaymentMethod | ||
[ShippingCartAddress]: {{page.baseurl}}/graphql/reference/quote.html#ShippingCartAddress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Attribute | Data Type | Description | ||
--- | --- | --- | ||
`id` | Int! | A unique ID assigned to the customizable option | ||
`value_string` | String! | A value assigned to the the customizable option |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
195 changes: 195 additions & 0 deletions
195
guides/v2.3/graphql/reference/quote-add-simple-products.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
--- | ||
group: graphql | ||
title: addSimpleProductsToCart mutation | ||
--- | ||
|
||
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. | ||
|
||
{:.bs-callout .bs-callout-info} | ||
The mutation for [adding configurable products]({{page.baseurl}}/graphql/reference/configurable-product.html) is defined in the `ConfigurableProductGraphQl` module. | ||
|
||
## Syntax | ||
|
||
`mutation: {addSimpleProductsToCart(input: AddSimpleProductsToCartInput): {AddSimpleProductsToCartOutput}}` | ||
|
||
## Example usage | ||
|
||
These examples show the minimal payload and a payload that includes customizable options. | ||
|
||
### Add a simple product to a cart | ||
|
||
The following example adds a simple product to a cart. The response contains the entire contents of the customer's cart. | ||
|
||
**Request** | ||
|
||
```text | ||
mutation { | ||
addSimpleProductsToCart( | ||
input: { | ||
cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", | ||
cart_items: [ | ||
{ | ||
data: { | ||
quantity: 1 | ||
sku: "24-MB04" | ||
} | ||
} | ||
] | ||
} | ||
) { | ||
cart { | ||
items { | ||
id | ||
product { | ||
name | ||
sku | ||
} | ||
quantity | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
**Response** | ||
|
||
```json | ||
{ | ||
"data": { | ||
"addSimpleProductsToCart": { | ||
"cart": { | ||
"items": [ | ||
{ | ||
"id": "13", | ||
"product": { | ||
"name": "Strive Shoulder Pack", | ||
"sku": "24-MB04" | ||
}, | ||
"quantity": 1 | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Add a simple product with customizable options to a cart | ||
|
||
If a product has a customizable option, you can specify the option's value in the `addSimpleProductsToCart` request. | ||
|
||
**Request** | ||
|
||
``` text | ||
mutation { | ||
addSimpleProductsToCart (input: { | ||
cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", | ||
cart_items: { | ||
data: { | ||
sku: "simple" | ||
quantity: 1 | ||
}, | ||
customizable_options: [ | ||
{ | ||
id: 121 | ||
value_string: "field value" | ||
} | ||
] | ||
} | ||
}) { | ||
cart { | ||
items { | ||
product { | ||
name | ||
} | ||
quantity | ||
... on SimpleCartItem { | ||
customizable_options { | ||
label | ||
values { | ||
value | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
**Response** | ||
|
||
```text | ||
{ | ||
"data": { | ||
"addSimpleProductsToCart": { | ||
"cart": { | ||
"items": [ | ||
{ | ||
"product": { | ||
"name": "simple" | ||
}, | ||
"quantity": 1, | ||
"customizable_options": [ | ||
{ | ||
"label": "Field Option", | ||
"values": [ | ||
{ | ||
"value": "field value" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Input attributes | ||
|
||
The top-level `AddSimpleProductsToCartInput` object is listed first. All child objects are listed in alphabetical order. | ||
|
||
### AddSimpleProductsToCartInput object {#AddSimpleProductsToCartInput} | ||
|
||
The `AddSimpleProductsToCartInput` object must contain the following attributes: | ||
|
||
Attribute | Data Type | Description | ||
--- | --- | --- | ||
`cart_id` | String! | The unique ID that identifies the customer's cart | ||
`cart_items` | [SimpleProductCartItemInput!](#SimpleProductCartItemInput) | Contains the cart item IDs and quantity of each item | ||
|
||
### CartItemInput object {#CartItemInputSimple} | ||
|
||
The `CartItemInput` object must contain the following attributes: | ||
|
||
{% include graphql/customizable-option-input.md %} | ||
|
||
### CustomizableOptionInput object {#CustomizableOptionInputSimple} | ||
|
||
The `CustomizableOptionInput` object must contain the following attributes: | ||
|
||
{% include graphql/customizable-option-input.md %} | ||
|
||
### SimpleProductCartItemInput object {#SimpleProductCartItemInput} | ||
|
||
The `SimpleProductCartItemInput` object must contain the following attributes: | ||
|
||
`customizable_options` |[[CustomizableOptionInputSimple]](#CustomizableOptionInputSimple) | An array that defines customizable options for the product | ||
`data` | [CartItemInput!](#CartItemInputSimple) | An object containing the `sku` and `quantity` of the product. | ||
|
||
## Output attributes | ||
|
||
The `AddSimpleProductsToCartOutput` object contains the `Cart` object. | ||
|
||
Attribute | Data Type | Description | ||
--- | --- | --- | ||
`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart | ||
|
||
### Cart object {#CartObject} | ||
|
||
{% include graphql/cart-object.md %} | ||
|
||
[Cart query output]({{page.baseurl}}/graphql/reference/quote.html#cart-output) provides more information about the `Cart` object. |
Oops, something went wrong.