01 Software

Orders & Tracking

Create orders, check status, track shipments, view returns and fulfillments

Orders & Tracking

Flow

Create order → Pending payment → Paid → Fulfillment → Shipping → Delivered

                                              Return request → Processing

Create Order

Orders are created via the Server API. Two methods: direct creation or cart checkout.

import { createServerClient, generateOrderNumber } from '@01.software/sdk'

const serverClient = createServerClient({
  publishableKey: process.env.NEXT_PUBLIC_SOFTWARE_PUBLISHABLE_KEY!,
  secretKey: process.env.SOFTWARE_SECRET_KEY!,
})

// Direct order creation
const order = await serverClient.api.createOrder({
  orderNumber: generateOrderNumber(),
  customerSnapshot: { name: 'John Doe', email: 'john@example.com', phone: '010-1234-5678' },
  shippingAddress: {
    recipientName: 'John Doe',
    phone: '010-1234-5678',
    postalCode: '06123',
    address1: '123 Main St',
    address2: 'Apt 4B',
  },
  orderProducts: [
    { product: 'product_id', variant: 'variant_id', option: 'option_id', quantity: 2, unitPrice: 10000 },
  ],
  totalAmount: 20000,
  paymentId: 'pay_123456', // optional for free orders
})

// Cart → Order checkout
const order2 = await serverClient.api.checkout({
  cartId: 'cart_id',
  orderNumber: generateOrderNumber(),
  customerSnapshot: { name: 'John Doe', email: 'john@example.com' },
  paymentId: 'pay_789',
})

customerSnapshot is a snapshot of customer info at order time. See Server API for detailed parameters.

Order Statuses

StageStatus flow
Paymentpendingpaidfailed / canceled
Shippingpreparingshippeddeliveredconfirmed
Returnsreturn_requestedreturn_processingreturned

Query Orders

// My orders
const { docs: orders } = await client.from('orders').find({
  where: { customer: { equals: customerId } },
  sort: '-createdAt',
  limit: 10
})

// Order detail (with order products)
const order = await client.from('orders').findById(orderId, { depth: 1 })

// Order items
const { docs: items } = await client.from('order-items').find({
  where: { order: { equals: orderId } },
  depth: 1  // includes product, variant, option info
})

Payment Status

// Payment history for an order
const { docs: transactions } = await client.from('transactions').find({
  where: { order: { equals: orderId } }
})
// transaction.status → 'pending' | 'paid' | 'failed' | 'canceled'
// transaction.amount, transaction.paymentMethod

Shipment Tracking

// Fulfillment info for an order
const { docs: fulfillments } = await client.from('fulfillments').find({
  where: { order: { equals: orderId } }
})
// fulfillment.carrier → free-form text (e.g. 'CJ Logistics', 'FedEx', 'UPS')
// fulfillment.trackingNumber
// fulfillment.status → 'pending' | 'packed' | 'shipped' | 'delivered' | 'failed'

// Fulfillment items detail
const { docs: items } = await client.from('fulfillment-items').find({
  where: { fulfillment: { equals: fulfillmentId } },
  depth: 1
})

View Returns

const { docs: returns } = await client.from('returns').find({
  where: { order: { equals: orderId } }
})
// return.status → 'requested' | 'approved' | 'rejected' | 'processing' | 'completed'
// return.reason → 'change_of_mind' | 'defective' | 'wrong_delivery' | 'damaged' | 'other'

// Return items detail
const { docs: returnItems } = await client.from('return-items').find({
  where: { return: { equals: returnId } },
  depth: 1
})

Collection Reference

For detailed field specifications, see Order Collections.

On this page