Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Cart checkout orders partials #185

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions docs/partials/_carts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
A cart contains a list of the products that a shopper adds to the cart while browsing your catalog. In the context of a cart, a selected product is called a cart item.

A cart item identifies the product, the product price, the quantity selected, and the total price for the quantity selected. The cart displays a running total of the cost for the selected products plus the calculated tax.

You can allow your shoppers to add custom text to a product when adding an item to their carts. This is useful, for example, if you have a product like a T-shirt that can be personalized. See [Add product to cart](/docs/api/carts/cart-merge#add-product-to-cart).

After a shopper checks out, the cart is converted to an order, and you can manually delete the cart. If you donʼt delete the cart, it is purged automatically after seven days.

The preview cart feature allows you to set a future date for your shopping cart and view the promotions that will be available during that time period. This feature enables you to validate your promotion settings and observe how they will be applied in the cart. See [Create a Preview Cart](/docs/carts-orders/create-multi-cart#post-create-a-preview-cart).

The following diagram shows a typical cart workflow:

![Shows a cart workflow, starting from adding the first item to a cart, through cart creation and checkout](/assets/cart-workflow.png)

### Multiple Carts

Buyers often make purchases based on jobs that they need to perform or outcomes they need to achieve and therefore require more than one shopping cart. For example, a corporate buyer places orders for multiple locations. Each location has a different frequency of ordering and require different products. The buyer can create one cart per location, fill the carts, and then check out the carts quickly. Similarly, shoppers can also create multiple carts for the ease of managing various shopping experiences, such as birthdays or holidays.

Each cart is discrete and separate. Any updates or changes to one cart has no effect on the other carts. A cart persists, that is, it stays with the buyer or shopper even after they use the cart in a checkout. Carts remain available after a checkout.
50 changes: 50 additions & 0 deletions docs/partials/_checkout.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
The checkout workflow ties together many of the key concepts covered in this section. When a customer initiates the checkout process, an order is created from the cart. The order is incomplete until after a successful payment is made. A complete order can be shipped and the product deducted from inventory counts.

![Checkout workflow](/assets/checkout-flow.png)

### Summary of the checkout workflow

1. Add a product to a cart. A cart and its reference number is generated.
2. Manage the cart items. For example, you might add items, remove items, and change quantities.
3. Check out the cart. An incomplete order is created.
4. Pay for an order: provide billing and shipping details, if you are a new customer. The order is now in the processing status.
5. If using a manual gateway, after you authorize and capture it, Composable Commerce considers the order complete. If you use a third-party integration supported by Composable Commerce (such as Stripe), after the third-party gateway authorizes and captures the payment, the order becomes complete. Usually capture does not occur at the same time as authorization. For more information, see the Capture section.
6. After the order is shipped, you can manually flag it as fulfilled.

### Carts

When a product is added to a cart, a cart is generated together with its unique reference ID that on checkout becomes a part of the order ID. If you are using our JavaScript software development kit, generating a cart reference ID is done for you; otherwise, add a cart reference generator to your functionality.

### Promotions and custom items

Optionally, apply a promotion code on a cart, or add custom_items to modify the product price (typically to handle taxes, customs, or shipping).

### Checkout

You can checkout a cart with an associated customer name and email (customer object). Typically, this would be used for new customers or ones that prefer to shop as guests. Use the customer.id checkout option to checkout for an existing customer. After a successful checkout is completed, the response contains an order.

Email addresses that either begin or end with a period, or contain consecutive periods, are considered invalid, resulting in the following error:
```json
"errors": [
{
"status": 400,
"source": "data.customer.email",
"title": "format",
"detail": "Does not match format 'email"
}
]
```

### Payments

On checkout, an incomplete order is created. You can then use a third-party integration to handle your payment gateway. If the payment gateway is supported by Composable Commerce, such as Stripe, the payment is processed externally but handled internally. When a successful validation is returned, Composable Commerce flags the order as complete.

If you are using a payment method not officially supported by Composable Commerce, the gateway needs to be implemented and handled manually. After the payment has been authorized and captured either through Commerce Manager or API, the status of an order becomes complete.

### Shipping

The status of an order and the status of shipping are handled separately, and so an order can be complete but not shipped. Orders that have not been shipped yet have a status of unfulfilled. This flag is generated automatically by Composable Commerce when an order is created. Currently, you can only update the shipping status manually, through the API. After the order is shipped, flag its shipping status as fulfilled.

### Inventory

If enabled, you can manage your stock. As such, your stock is automatically updated as soon as a product is checked out.
9 changes: 9 additions & 0 deletions docs/partials/_orders.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
An Order is created through the [checkout](/docs/api/carts/checkout) endpoint within the Carts API.

An order is created after a customer checks out their cart. On creation, the order is marked unpaid. The customer is prompted for a shipping address, a billing address, and a payment method. After the order is successfully paid, you can trigger an inventory process and a shipping process.

You can keep a history of orders associated with the customer account.

### Reorder

A re-order is when a shopper copies items from a previous order from their order history into a cart of their choice. If a shopper re-orders to an empty cart, the same quantities as the past order are applied. If the shopper re-orders to an existing cart, and orders the same item, the quantity increases. If an item is out of stock, the item is not added to the cart, and the shopper sees an insufficient stock error. The tax for the items in a re-order is not applied. For more information, see [Tax Items](/docs/api/carts/tax-items).
5 changes: 5 additions & 0 deletions guides/key-concepts/carts/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"position": 5,
"label": "Carts",
"collapsible": true
}
9 changes: 9 additions & 0 deletions guides/key-concepts/carts/carts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Carts
nav_label: Carts
sidebar_position: 10
---

import Carts from "/docs/partials/_carts.mdx";

<Carts></Carts>
5 changes: 5 additions & 0 deletions guides/key-concepts/checkout/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"position": 6,
"label": "Checkout",
"collapsible": true
}
9 changes: 9 additions & 0 deletions guides/key-concepts/checkout/checkout.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Checkout
nav_label: Checkout
sidebar_position: 10
---

import Checkout from "/docs/partials/_checkout.mdx";

<Checkout></Checkout>
5 changes: 5 additions & 0 deletions guides/key-concepts/orders/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"position": 7,
"label": "Orders",
"collapsible": true
}
9 changes: 9 additions & 0 deletions guides/key-concepts/orders/orders.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Orders
nav_label: Orders
sidebar_position: 10
---

import Orders from "/docs/partials/_orders.mdx";

<Orders></Orders>