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

Graphql checkout tutorial #4271

Merged
merged 44 commits into from
Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
279bf7a
magento/devdocs#589: Add a tutorial for the checkout workflow
atwixfirster Apr 14, 2019
9b5d929
magento/devdocs#589: Add a tutorial for the checkout workflow
atwixfirster Apr 15, 2019
4c4d872
magento/devdocs#589: Add a tutorial for the checkout workflow
atwixfirster Apr 16, 2019
53de037
magento/devdocs#589: Add a tutorial for the checkout workflow
atwixfirster Apr 16, 2019
bac65d8
magento/devdocs#589: Add a tutorial for the checkout workflow
atwixfirster Apr 16, 2019
65bdfa5
magento/devdocs#589: Add a tutorial for the checkout workflow
atwixfirster Apr 17, 2019
d73f31b
adding navigation
keharper Apr 19, 2019
3997578
Update graphql.yml
keharper Apr 19, 2019
1d194d3
magento/devdocs#589: Add a tutorial for the checkout workflow
atwixfirster Apr 19, 2019
4cbb1cd
Merge branch 'graphql-checkout-tutorial' of https://github.com/atwixf…
atwixfirster Apr 19, 2019
ec245f1
magento/devdocs#: GraphQl Checkout Tutorial
atwixfirster Apr 19, 2019
ba75eda
magento/devdocs#: GraphQl Checkout Tutorial
atwixfirster Apr 21, 2019
5e63193
magento/devdocs#: GraphQl checkout tutorial
atwixfirster Jun 1, 2019
f8186c9
magento/devdocs#: GraphQl checkout tutorial
atwixfirster Jun 1, 2019
73d278c
magento/devdocs#: GraphQl checkout tutorial. Updates for checkout-add…
atwixfirster Jun 1, 2019
64dc8be
magento/devdocs#: GraphQl checkout tutorial. Updates for checkout-add…
atwixfirster Jun 1, 2019
a155024
magento/devdocs#: GraphQl checkout tutorial. Updates for checkout-bil…
atwixfirster Jun 1, 2019
48bd363
magento/devdocs#: GraphQl checkout tutorial. Updates for checkout-cou…
atwixfirster Jun 1, 2019
baf4720
magento/devdocs#: GraphQl checkout tutorial. Updates for checkout-cus…
atwixfirster Jun 1, 2019
32467d8
magento/devdocs#: GraphQl checkout tutorial. Updates for checkout-pay…
atwixfirster Jun 1, 2019
1f42e9f
magento/devdocs#: GraphQl checkout tutorial. Updates for checkout-pla…
atwixfirster Jun 1, 2019
13f28b4
magento/devdocs#: GraphQl checkout tutorial. Updates for checkout-quo…
atwixfirster Jun 2, 2019
589e90c
magento/devdocs#: GraphQl checkout tutorial. Updates for checkout-shi…
atwixfirster Jun 2, 2019
3579c4c
magento/devdocs#: GraphQl checkout tutorial. Updates for checkout-shi…
atwixfirster Jun 2, 2019
75fbc4e
magento/devdocs#: GraphQl checkout tutorial. Updates for checkout-sho…
atwixfirster Jun 2, 2019
e5c01a8
magento/devdocs#: GraphQl checkout tutorial. Updates for index.md
atwixfirster Jun 2, 2019
4249345
magento/devdocs#: GraphQl checkout tutorial. Update product types
atwixfirster Jun 3, 2019
a9812fe
magento/devdocs#: GraphQl checkout tutorial. Updates for checkout-bil…
atwixfirster Jun 3, 2019
71208e5
magento/devdocs#: GraphQl checkout tutorial. Updates for checkout-cou…
atwixfirster Jun 3, 2019
5b2e9eb
magento/devdocs#: GraphQl checkout tutorial. Add virtual product to cart
atwixfirster Jun 3, 2019
b2b1e8a
magento/devdocs#: GraphQl checkout tutorial.
atwixfirster Jun 4, 2019
d3fe88f
magento/devdocs#: GraphQl checkout tutorial.
atwixfirster Jun 5, 2019
2b1ad2e
magento/devdocs#: GraphQl checkout tutorial.
atwixfirster Jun 5, 2019
8463855
magento/devdocs#: GraphQl checkout tutorial.
atwixfirster Jun 5, 2019
40e4ffe
magento/devdocs#: GraphQl checkout tutorial.
atwixfirster Jun 10, 2019
b12304e
magento/devdocs#: GraphQl checkout tutorial.
atwixfirster Jun 10, 2019
0af7e16
magento/devdocs#: GraphQl checkout tutorial.
atwixfirster Jun 24, 2019
a392479
magento/devdocs#: GraphQl checkout tutorial.
atwixfirster Jun 24, 2019
f61227d
magento/devdocs#: GraphQl checkout tutorial.
atwixfirster Jun 24, 2019
ce51831
Update index.md
keharper Jun 25, 2019
5471840
Update checkout-add-product-to-cart.md
keharper Jun 25, 2019
cd6b436
Merge branch 'master' into graphql-checkout-tutorial
keharper Jun 25, 2019
d0562f3
Merge branch 'master' into graphql-checkout-tutorial
keharper Jun 25, 2019
2d4e911
Update checkout-billing-address.md
keharper Jun 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions _data/toc/graphql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pages:
children:
- label: CMS endpoint
url: /graphql/reference/cms.html

- label: CustomAttributeMetadata endpoint
url: /graphql/reference/custom-attribute-metadata.html

Expand Down Expand Up @@ -94,6 +94,10 @@ pages:

- label: Wishlist endpoint
url: /graphql/reference/wishlist.html


- label: Tutorial
class: tutorial
url: /graphql/tutorials/checkout/index.html

- label: Release Notes
url: /graphql/release-notes.html
url: /graphql/release-notes.html
149 changes: 149 additions & 0 deletions guides/v2.3/graphql/tutorials/checkout/checkout-add-product-to-cart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
---
layout: tutorial
group: graphql
title: Step 3. Add product to cart
subtitle: GraphQL checkout tutorial
level3_subgroup: graphql-checkout
return_to:
title: GraphQL Overview
url: graphql/index.html
menu_order: 30
functional_areas:
- Integration
contributor_name: Atwix
contributor_link: https://www.atwix.com/
---

GraphQL supports [2 types of product]({{ page.baseurl }}/graphql/reference/product-interface-implementations.html) which can be added into shopping cart:
keharper marked this conversation as resolved.
Show resolved Hide resolved

* simple product
* virtual product

{:.bs-callout .bs-callout-info}
keharper marked this conversation as resolved.
Show resolved Hide resolved
If you add a product to the shopping cart as a registered customer, be sure to send the customer's authorization token in the `Authorization` parameter of the header. See ["Get customer authorization token"]({{ page.baseurl }}/graphql/get-customer-authorization-token.html) for more details.

`{{ CART_ID }}` is the unique shopping cart ID from [Step 2. Create empty cart]({{ page.baseurl }}/graphql/tutorials/checkout/checkout-add-product-to-cart.html).

## Add a simple product into shopping cart

The following mutation adds a **simple product** into shopping cart.

**Request**
keharper marked this conversation as resolved.
Show resolved Hide resolved

```text
mutation {
addSimpleProductsToCart(
input: {
cart_id: "{{ CART_ID }}"
cart_items: [
{
data: {
qty: 1
keharper marked this conversation as resolved.
Show resolved Hide resolved
sku: "simple-product"
}
}
]
}
) {
cart {
items {
id
product {
sku
stock_status
}
qty
}
}
}
}
```

**Response**

```json
{
"data": {
"addSimpleProductsToCart": {
"cart": {
"items": [
{
"id": "508",
"product": {
"sku": "simple-product",
"stock_status": "IN_STOCK"
},
"qty": 1
}
]
}
}
}
}
```

## Add a virtual product into shopping cart

The following mutation adds a **virtual product** into shopping cart.

**Request**

```text
mutation {
addVirtualProductsToCart(
input: {
cart_id: "{{ CART_ID }}"
cart_items: [
{
keharper marked this conversation as resolved.
Show resolved Hide resolved
data: {
qty: 1
sku: "virtual-product"
}
}
]
}
) {
cart {
items {
id
product {
sku
stock_status
}
qty
}
}
}
}
```

**Response**

```json
{
"data": {
"addVirtualProductsToCart": {
"cart": {
"items": [
{
"id": "509",
"product": {
"sku": "virtual-product",
"stock_status": "IN_STOCK"
},
"qty": 1
}
]
}
}
}
}
```

Use the `updateCartItems` mutation to update shopping cart items and `removeItemFromCart` to remove a product from the shopping cart.

## Verify this step {#verify-step}

1. Sign in as a customer to the website using the email `john.doe@example.com` and password `b1b2b3l@w+`.

keharper marked this conversation as resolved.
Show resolved Hide resolved
2. Go to the shopping cart. All the items you added are displayed.
Loading