Overview
ThecreateCart mutation initializes a new shopping cart for a customer. This is the first step in the checkout flow and must be called before adding items to the cart.
GraphQL Mutation
Parameters
The cart data object
Response
Unique identifier for the created cart
Customer’s email address
Cart type (default, swap, draft_order, etc.)
The region associated with this cart
Array of line items in the cart (empty at creation)
Array of shipping methods (automatically populated with cheapest option for the region)
Example Request
Behavior
Automatic User Association
If a user is authenticated when creating a cart, the cart is automatically associated with that user’s account.Automatic Shipping Method
When a cart is created with a region, the system automatically:- Finds the cheapest shipping option for that region
- Creates a shipping method record
- Associates it with the cart
Region Requirements
Theregion parameter is required because it determines:
- Currency for all prices
- Tax rates to apply
- Available shipping options
- Available payment providers
Next Steps
After creating a cart:- Add items to the cart
- Set shipping and billing addresses
- Select shipping method (or use the default)
- Create payment sessions
- Complete the cart to create an order
Related
- Add to Cart - Add product variants to the cart
- Complete Cart - Convert cart to order