Orders & Tracking
Create orders, check status, track shipments, view returns/exchanges
Orders & Tracking
Flow
Create order → Pending payment → Paid → Fulfillment → Shipping → Delivered
↓
Return/Exchange request → ProcessingCreate Order
const order = await client.from('orders').create({
customer: customerId,
cart: cartId,
shippingAddress: {
recipientName: 'John Doe',
phone: '010-1234-5678',
postalCode: '06123',
address1: '123 Main St',
address2: 'Apt 4B'
}
})
// order.orderNumber → auto-generated order numbercustomerSnapshot automatically captures customer info at order time.
Order Statuses
| Stage | Status flow |
|---|---|
| Payment | pending → paid → failed / canceled |
| Shipping | preparing → shipped → delivered → confirmed |
| Returns | return_requested → return_processing → returned |
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 products
const { docs: items } = await client.from('order-products').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.totalAmount, transaction.methodShipment Tracking
// Fulfillment info for an order
const { docs: fulfillments } = await client.from('fulfillments').find({
where: { order: { equals: orderId } }
})
// fulfillment.carrier → 'cj' | 'hanjin' | 'lotte' | 'epost' | 'logen' | 'other'
// fulfillment.trackingNumber
// fulfillment.status → 'pending' | 'shipped' | 'delivered'
// 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-products').find({
where: { return: { equals: returnId } },
depth: 1
})View Exchanges
const { docs: exchanges } = await client.from('exchanges').find({
where: { order: { equals: orderId } }
})
// exchange.reason → 'wrong_size' | 'wrong_color' | 'defective' | 'other'Collection Reference
For detailed field specifications, see Order Collections.