Create a cart and go to checkout#
This guide walks through the complete cart-to-checkout flow: creating a cart, adding products, setting a shipping address and method, then confirming the cart to receive an order with a checkout URL.
Overview#
- Create an empty cart with
createCart - Add products by SKU with
addItemsToCart - Set a shipping address with
addShippingAddressToCart - Choose a shipping method with
addShippingMethodToCart - Verify the cart is valid, then confirm it with
confirmCart - Redirect the customer to the checkout URL
Step 1 — Create a cart#
createCart takes no input.
Returns: Cart
| Name | Type | Required | Description |
|---|---|---|---|
id | ID! | Required | The ID of the cart |
number | String! | Required | Cart number |
total | Money! | Required | Total value |
subtotal | Money! | Required | Total before discounts |
Save the returned cart.id — you'll pass it as cart_id in every subsequent mutation.
channel_id if you operate multiple storefronts. Pass country_code to pre-set the delivery country and ensure correct tax calculation from the start.Step 2 — Add items#
Input: AddItemsToCartInput!
| Name | Type | Required | Description |
|---|---|---|---|
cart_id | String! | Required | ID of the cart returned in step 1. |
items | [ItemInput!]!▾ | Required | Items to add. |
Returns: Cart
| Name | Type | Required | Description |
|---|---|---|---|
id | ID! | Required | The ID of the cart |
number | String! | Required | Cart number |
total | Money! | Required | Total value |
subtotal | Money! | Required | Total before discounts |
Step 3 — Set a shipping address#
Input: AddShippingAddressToCartInput!
| Name | Type | Required | Description |
|---|---|---|---|
cart_id | String! | Required | ID of the cart. |
address | AddressInput!▾ | Required | Delivery address. |
Returns: Cart
| Name | Type | Required | Description |
|---|---|---|---|
id | ID! | Required | The ID of the cart |
number | String! | Required | Cart number |
total | Money! | Required | Total value |
subtotal | Money! | Required | Total before discounts |
Step 4 — Choose a shipping method#
First, query the available shipping methods for your channel:
Then apply one to the cart:
Input: AddShippingMethodToCartInput!
| Name | Type | Required | Description |
|---|---|---|---|
cart_id | String! | Required | ID of the cart. |
method_id | String! | Required | ID of the shipping method to apply. |
Returns: Cart
| Name | Type | Required | Description |
|---|---|---|---|
id | ID! | Required | The ID of the cart |
number | String! | Required | Cart number |
total | Money! | Required | Total value |
subtotal | Money! | Required | Total before discounts |
Step 5 — Verify and confirm#
Before confirming, check that the cart has no validation errors:
Once valid, confirm the cart to convert it into an order:
Input: ConfirmCartInput!
| Name | Type | Required | Description |
|---|---|---|---|
cart_id | String! | Required | ID of the cart to confirm. |
Returns: Order
| Name | Type | Required | Description |
|---|---|---|---|
id | ID! | Required | The ID |
number | String! | Required | Order number |
total | Money! | Required | Total value |
currency | Currency! | Required | Currency code |
Redirect the customer to order.checkout.url to complete payment.
Notes#
confirmCartfails ifcart.validation_errorsis non-empty — ensure items, shipping address, and shipping method are all set.Moneyvalues (total,subtotal) are integers in cents — e.g.2499means € 24,99.- To add a billing address before confirming, use
addBillingAddressToCartwith the sameAddressInputshape. - To add a payment method before confirming, use
addPaymentMethodToCartwithmethod_idand the requiredissuer_id. - See Authentication for how to pass your API key.