Create Your First Order
This guide walks you through the complete checkout flow to create your first order.
Prerequisites
- Unchained Engine running locally (see Initialize and Run)
- At least one product created (see Your First Product)
- Payment and delivery providers configured
Using the Storefront
The easiest way to create an order is through the storefront.
1. Browse Products
- Open http://localhost:3000
- Browse the product catalog
- Find the product you created
2. Add to Cart
- Click on a product to view details
- Select quantity
- Click Add to Cart
3. View Cart
- Click the cart icon
- Review your items
- Adjust quantities if needed
4. Checkout
- Click Proceed to Checkout
- If prompted, log in or continue as guest
- Enter shipping address
- Select delivery method
- Select payment method
- Review order total
- Click Place Order
5. Confirm Order
After placing the order:
- You'll see an order confirmation page
- Check the Admin UI for the new order
- Email confirmation will be sent (check the built-in email preview)
Using GraphQL
For testing or programmatic orders, use the GraphQL API.
Step 1: Login as Guest
mutation LoginAsGuest {
loginAsGuest {
_id
tokenExpires
user {
_id
isGuest
}
}
}
Unchained uses cookie-based authentication. When you call loginAsGuest (or any login mutation), the server responds with a Set-Cookie header containing unchained_token.
In the GraphQL Playground:
- Cookies are automatically handled if you enable "request.credentials" in settings
- Go to Settings (gear icon) and set
"request.credentials": "include"
In your application:
- Ensure your HTTP client is configured to include credentials (cookies)
- Example with fetch:
fetch(url, { credentials: 'include' })
Step 2: Add Product to Cart
mutation AddToCart {
addCartProduct(productId: "your-product-id", quantity: 1) {
_id
quantity
product {
texts {
title
}
}
total {
amount
currencyCode
}
order {
_id
total {
amount
currencyCode
}
}
}
}
Step 3: Get Available Providers & Set Delivery/Payment
Get available delivery and payment providers:
query GetProviders {
me {
cart {
supportedDeliveryProviders {
_id
type
interface { label }
}
supportedPaymentProviders {
_id
type
interface { label }
}
}
}
}
Set both providers in one call:
mutation SetProviders {
updateCart(
deliveryProviderId: "your-delivery-provider-id"
paymentProviderId: "your-payment-provider-id"
) {
_id
delivery {
provider { interface { label } }
}
payment {
provider { interface { label } }
}
}
}
Step 4: Set Delivery Address
mutation SetDeliveryAddress {
updateCartDeliveryShipping(
deliveryProviderId: "your-delivery-provider-id"
address: {
firstName: "John"
lastName: "Doe"
addressLine: "123 Main Street"
postalCode: "8000"
city: "Zurich"
countryCode: "CH"
}
) {
_id
}
}
Step 5: Set Billing Address
A billing address is required for checkout. Without it, the checkout will fail with OrderCheckoutError: Billing address not provided.
mutation SetBillingAddress {
updateCart(billingAddress: {
firstName: "John"
lastName: "Doe"
addressLine: "123 Main Street"
postalCode: "8000"
city: "Zurich"
countryCode: "CH"
}) {
_id
billingAddress {
firstName
lastName
city
}
}
}
Step 6: Review & Checkout
Review your cart and checkout in one step:
query ReviewCart {
me {
cart {
_id
items {
quantity
product { texts { title } }
total { amount currencyCode }
}
delivery {
... on OrderDeliveryShipping {
address { firstName lastName city }
}
fee { amount currencyCode }
}
payment {
provider { interface { label } }
fee { amount currencyCode }
}
total { amount currencyCode }
}
}
}
Step 7: Checkout
mutation Checkout {
checkoutCart {
_id
status
orderNumber
ordered
total {
amount
currencyCode
}
}
}
Understanding Order Status
After checkout, your order will have one of these statuses:
| Status | Meaning | Next Step |
|---|---|---|
PENDING | Awaiting payment confirmation | Payment webhook or manual confirmation |
CONFIRMED | Payment received, ready for delivery | Process delivery |
FULFILLED | Delivered and complete | None - order finished |
For the default Invoice payment provider, orders typically go directly to CONFIRMED since isPayLaterAllowed returns true.
Viewing Orders
In Admin UI
- Open http://localhost:4010
- Click Orders in the sidebar
- Find your order by order number
- Click to view details
Via GraphQL
As admin:
query GetOrders {
orders(limit: 10) {
_id
orderNumber
status
ordered
user {
primaryEmail {
address
}
}
total {
amount
currencyCode
}
}
}
Single order:
query GetOrder($orderId: ID!) {
order(orderId: $orderId) {
_id
orderNumber
status
items {
quantity
product {
texts {
title
}
}
total {
amount
currencyCode
}
}
delivery {
... on OrderDeliveryShipping {
address {
firstName
lastName
addressLine
city
}
}
status
}
payment {
status
}
total {
amount
currencyCode
}
}
}
Managing Orders
Confirm Order Manually
If order is in PENDING status:
mutation ConfirmOrder {
confirmOrder(orderId: "order-id") {
_id
status
}
}
Reject Order
mutation RejectOrder {
rejectOrder(orderId: "order-id") {
_id
status
}
}
Mark as Delivered
mutation MarkDelivered {
deliverOrder(orderId: "order-id") {
_id
status
delivery {
status
}
}
}
Common Issues
"No delivery provider" Error
- Ensure you've created at least one delivery provider in Admin UI
- Check that the delivery provider is active
- Verify the delivery provider supports your country
"No payment provider" Error
- Create at least one payment provider in Admin UI
- Ensure it's active
- For testing, use the Invoice provider with "Pay Later" enabled
Order Stuck in PENDING
- Check payment provider configuration
- For Invoice provider, orders should auto-confirm
- For card payments, verify webhook is set up correctly
Cart is Empty
- Ensure you're authenticated (guest or registered)
- Check that
Authorizationheader is set correctly - Verify products are published
Order Lifecycle Diagram
Next Steps
Now that you've created your first order, explore:
- Order Lifecycle - Understand order states
- Payment Integration - Set up real payments
- Checkout Implementation - Build custom checkout
- Platform Configuration - Customize your shop