Commerce (Orders)

The Commerce module handles the transaction layer — orders, carts, payments, discounts, and affiliates. An agent can manage the entire order lifecycle from cart to fulfillment.

Order

Orders represent purchase transactions — what was bought, by whom, payment status, and fulfillment tracking.

FieldTypeDescription
id / uuidID!Unique identifiers
order_numberStringHuman-readable order number
statusStringOrder status (draft, confirmed, etc.)
fulfillment_statusStringFulfillment state
total_gross_amountFloatTotal including tax
total_net_amountFloatTotal excluding tax
discount_amountFloatDiscount applied
currencyStringCurrency code
customer_noteStringNote from customer
peoplePeopleCustomer / contact
items[OrderItem!]Line items (paginated)
shipping_addressAddressShipping address
custom_fields[CustomField!]Custom data
files[Filesystem!]Attached files

OrderItem

FieldTypeDescription
idID!Unique identifier
product_nameStringProduct name at time of purchase
product_skuStringSKU at time of purchase
quantityIntQuantity ordered
unit_price_gross_amountFloatUnit price including tax
variantVariantLinked variant
quantity_fulfilledIntQuantity fulfilled so far
# List orders
query {
  orders(first: 20, orderBy: [{ column: CREATED_AT, order: DESC }]) {
    data {
      id order_number status fulfillment_status
      total_gross_amount currency customer_note
      people { name email }
      items(first: 50) {
        data { product_name product_sku quantity unit_price_gross_amount }
      }
      shipping_address { address city state zip country }
      created_at
    }
    paginatorInfo { total hasMorePages }
  }
}

# Create a draft order
mutation {
  createDraftOrder(input: {
    people_id: 1
    items: [{ variant_id: 1, quantity: 2 }]
    shipping_address: { address: "123 Main St", city: "New York", state: "NY", zip: "10001", country: "US" }
    customer_note: "Please gift wrap"
  }) {
    id order_number status total_gross_amount
  }
}

# Update order status
mutation {
  updateOrder(id: 1, input: { status: "confirmed", fulfillment_status: "processing" }) {
    id status fulfillment_status
  }
}

Cart

FieldTypeDescription
idID!Cart identifier
items[CartItem!]Items in the cart
discounts[CartDiscount!]Applied discounts
subtotalFloatSubtotal before discounts
totalFloatFinal total
# Add to cart
mutation {
  addToCart(input: { variant_id: 1, quantity: 2 }) {
    id
    items { name price quantity }
    subtotal total
  }
}

# Apply discount code
mutation {
  cartDiscountCodesUpdate(codes: ["SAVE20"]) {
    id discounts { code amount } total
  }
}

# Create order from cart
mutation {
  createOrderFromCart(input: {
    cart_id: 1
    shipping_address: { address: "123 Main St", city: "New York", state: "NY", zip: "10001", country: "US" }
  }) {
    id order_number total_gross_amount
  }
}

Payments

# Generate payment intent
mutation {
  generateOrderPaymentIntent(order_id: 1) {
    paymentIntent
    message
  }
}

# Process payment
mutation {
  processOrderPayment(input: { order_id: 1, payment_method_id: "pm_xxx" }) {
    status message
    order { id status }
  }
}