Skip to content

Orders

Order Lifecycle

Orders move through a defined set of statuses. Transitions are strictly enforced — only the arrows below are valid.

pending → confirmed → processing → shipped → delivered → refunded
    ↓           ↓            ↓
 cancelled  cancelled    cancelled
StatusMeaning
pendingOrder placed, awaiting confirmation
confirmedConfirmed, not yet being processed
processingBeing prepared / packed
shippedHanded to carrier
deliveredReceived by customer
cancelledCancelled (terminal)
refundedRefunded (terminal)

Every status change is recorded in OrderStatusHistory with an optional comment.

Order Fields

FieldTypeDescription
idUUIDUnique identifier
order_numberstringHuman-readable order number
customer_idUUID?Link to customer (null for guest orders)
statusstringCurrent status
currencystringISO 4217 code
subtotal_netintNet subtotal in cents
subtotal_grossintGross subtotal in cents
shipping_costintShipping cost in cents
tax_totalintTotal tax in cents
totalintGrand total in cents
billing_addressobjectBilling address snapshot
shipping_addressobjectShipping address snapshot
payment_method_idUUID?Selected payment method
shipping_method_idUUID?Selected shipping method
notesstringCustomer or admin notes
custom_fieldsobjectFree-form extra data

Order Items

Each OrderItem is a snapshot of what was purchased at the time of the order. Product name, SKU, and prices are copied so that later changes to the product catalogue do not affect historical orders.

FieldDescription
product_id / variant_idReference to the original product/variant
skuSnapshot of SKU at time of order
nameSnapshot of product name
quantityUnits ordered
unit_price_net / unit_price_grossPrice per unit in cents
total_net / total_grossLine total in cents
tax_rateTax rate in basis points (e.g. 1900 = 19%)

Guest Orders

customer_id is nullable. Orders from non-registered customers have no customer link — billing and shipping addresses are stored directly on the order.

Updating Order Status

Via the Admin API:

bash
curl -X PATCH http://localhost:8080/api/v1/admin/orders/<id>/status \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{"status": "shipped", "comment": "Tracking: DHL 12345"}'

Invalid transitions (e.g. deliveredpending) are rejected with a 422 error.

Released under the MIT License.