Skip to main content

Orders

A product order captures what was bought, what it costs, where it ships, and how it's fulfilled. Each order has one or more items (with the product, variant, and SKU captured at order time), a complete pricing breakdown including shipping and tax, a shipping address and fulfillment details, and a status that advances from received to delivered.

In the TypeScript SDK each order item references a variantId; the Python SDK identifies items by product_id and sku.

Product order lifecycleOrders flow pending, confirmed, preparing, ready, out_for_delivery, completed. Orders can be cancelled or returned. Payment status (pending, paid, partial, failed, refunded) tracks in parallel.ORDER STATUSpendingconfirmedpreparingreadyout_for_deliverycompletedcancelledreturnedexception statesPAYMENTpending · paid · partial · failed · refunded (tracked in parallel)

Create an order

const order = await client.productOrders.create({
customerId: 'cust_456',
orderDate: Date.now(),
items: [
{
productId: 'product_123',
variantId: 'variant_456',
itemName: 'Wireless Headphones',
quantity: 1,
unitPrice: 199.99,
totalPrice: 199.99,
},
],
pricing: {
subtotal: 199.99,
total: 199.99,
},
});

console.log(`Order Created: ${order.id}`);

Get and list

const order = await client.productOrders.get('order_123');
console.log(`${order.status} — $${order.pricing.total}`);

const result = await client.productOrders.list();
result.data.forEach(o => console.log(`- ${o.id}: ${o.status} ($${o.pricing.total})`));

Update, status, cancel, delete

Order updates, status transitions, cancellation, and deletion are exposed through the TypeScript SDK.

import { OrderStatus } from 'wiil-core-js';

const updated = await client.productOrders.update({
id: 'order_123',
pricing: { subtotal: 180.00, total: 180.00 },
});

const advanced = await client.productOrders.updateStatus('order_123', {
id: 'order_123',
status: OrderStatus.CONFIRMED,
});

const cancelled = await client.productOrders.cancel('order_123', {
cancelReason: 'Customer requested cancellation',
});

await client.productOrders.delete('order_123');

ProductOrder fields

FieldTypeRequiredDescription
idstringautoUnique identifier
statusenumNoOrder status (default pending)
itemsarrayYesOrder items (min 1)
customerIdstringYesCustomer reference
pricingobjectYesPricing breakdown (see below)
orderDatenumberYesUnix timestamp of placement
paymentStatusenumNopending, paid, partial, failed, refunded
paymentMethod / paymentReferencestring | nullNoPayment details
billingAddress / shippingAddressobject | nullNoAddresses (see OrderAddress)
shippingMethod / shippingCarrier / trackingNumberstring | nullNoFulfillment details
requestedDeliveryDate / shippedDate / deliveredDatenumber | nullNoFulfillment timing
locationId / channelId / terminalId / operatorIdstring | nullNoRouting & POS context
orderNumberstring | nullNoHuman-readable number (e.g. "ORD-12345")
sourcestringNoOrder source (default direct)
externalRefobject | nullNoExternal platform reference
cancelReason / notesstring | nullNoCancellation reason and staff notes

Pricing

The pricing object carries the full breakdown — subtotal and total are required; tax, shippingAmount, discount, tip, and currency are optional.

OrderAddress

street is required; city, state, postalCode, country, and deliveryInstructions are optional.

Order item (ProductOrderItemBase)

FieldTypeRequiredDescription
productIdstringYesProduct reference
variantIdstring | nullNoVariant reference (set on TypeScript order items)
itemNamestringYesName captured at order time
skustring | nullNoSKU captured at order time
quantityintegerYesQuantity (positive)
unitPricenumberYesPrice per unit at order time
totalPricenumberYesunitPrice × quantity
warrantyInfostring | nullNoWarranty terms captured at purchase
statusenumNoItem fulfillment status (default pending)

Status lifecycle

StatusMeaning
pendingOrder received, not started
confirmedConfirmed by the business
preparingWarehouse is picking/packing
readyReady for shipment
out_for_deliveryWith the carrier
completedDelivered
cancelledCancelled (with cancelReason)
returnedReturned

Query options

Orders filter by search, locationId, channelId, terminalId, operatorId, status[], paymentStatus[], customerId, externalSource, and dateRange, sorted by orderDate, createdAt, or totalAmount (asc / desc), with page/pageSize pagination.

tip

Item names, SKUs, and prices are captured at order time so records stay accurate when the catalog changes. Record trackingNumber and shippingCarrier for fulfillment visibility.