Skip to main content
This guide walks through the complete flow from adding items to a cart through redirecting to checkout.

Overview

Step 1: Create a Cart

First, create an empty cart. You’ll get back a cart_id that you’ll use for all subsequent operations.
Store the cart_id in localStorage or a cookie so it persists across page refreshes.

Step 2: Add Items to Cart

Add products to the cart using a variant ID. You can get variant IDs from the product endpoints.

Adding a bundle

A bundle (type: BUNDLE) has no variants of its own. To add it, pick one variant of every product in its offers and send them in a single request, all with the same quantity and with bundleId set to the bundle’s id:
The items are validated together: a missing product, a variant that does not belong to the bundle, or different quantities return 400 CART_INCOMPLETE_BUNDLE_ERROR. In the cart response the bundle’s items carry groupedBy: { "type": "BUNDLE", "bundleId", "groupedId" } - items with the same groupedId form one bundle instance, so you can render them as a group and price them with the bundle’s price.
The same items shape (including bundleId) is accepted when creating the cart in Step 1, so a bundle can be the first thing in a new cart.

Step 3: View Cart Contents

Fetch the current cart to display items to the user:

Step 4: Redirect to Checkout

When the customer is ready to purchase, redirect them to the Fourthwall checkout page using the cart ID:
The checkout URL format is:
Make sure to use your shop’s checkout domain, not storefront-api.fourthwall.com.

Alternative: Domain cart checkout URL

You can also use the domain cart-checkout entrypoint:

Alternative: Direct product checkout URL

If you want to skip cart creation and redirect from variant IDs directly, use:
For multiple variants:
quantity is optional and defaults to 1. For full behavior details, see Cart Checkout Endpoint.

Complete Example

Here’s a complete implementation you can adapt:

Next Steps

Style Your Checkout

Make your checkout page match your brand

Cart API Reference

See all cart operations