This repository was 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.7k
Draft: Reorg GraphQL quote topic #4502
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
33046d1
checkpoint
keharper d2929a7
fix broken links
keharper 11b4b8d
one mutation per topic
keharper b3375b6
Add consistency between topics
keharper 07e4918
Apply suggestions from code review
keharper 6270077
incorporate review comments
keharper 3e4234d
Merge branch 'kh_quote-reorg' of github.com:magento/devdocs into kh_q…
keharper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.