Orders creates an order from a basket and reads or updates the current end user’s orders. An order carries the basket’s items and currency, your own data fields (shipping, payment, notes), and platform-maintained status, totalAmount, and itemCount. Available wherever a current end user exists: tools, dynamic jobs, and trigger-fired turns (see execution contexts).
Verified against lua-cli 3.33.0.
Quick example
Methods
create()
Creates an order from a basket’s items.string
required
The basket to convert.
Record<string, any>
required
Your order fields, for example
shippingAddress, paymentMethod, and notes.any in the SDK; the platform requires basketId.
Returns — the order as an OrderInstance with status pending.
Example
Failed to create order.
updateStatus()
Sets an order’s status. The status comes first.OrderStatus
required
One of the
OrderStatus values.string
required
The order’s id.
OrderResponse
The raw order record, not an instance.
Failed to update order status.
updateData()
Merges fields into an order’sdata. The data comes first.
Record<string, any>
required
Fields to add or replace.
string
required
The order’s id.
updateStatus().
Example
Failed to update order data.
get()
Returns the current end user’s orders, optionally filtered by status.OrderStatus
Omit it for every order.
OrderInstance.
Example
Failed to get user orders.
getById()
Returns one order by id.OrderInstance. An unknown id throws; there is no null return.
Example
Failed to get order.
OrderInstance
The objectcreate(), get(), getById(), and Baskets.placeOrder() return. Every order field is readable directly through the instance’s proxy: status, totalAmount, itemCount, and currency from the platform, items, basketId, orderDate, createdAt, and your own data fields. Direct assignments stay local until save().
The identity fields id, orderId, userId, and agentId and the raw data and common objects are private in the type declarations, so order.id doesn’t compile. Read the id from order.toJSON().id. totalAmount is typed string | number; wrap it in Number() before arithmetic.
updateStatus()
Sets the status and refreshes the instance’s platform fields.{ ...data, ...common, id }.
update()
Merges fields intodata on the server and refreshes the instance.
{ ...data, ...common, id }.
save()
Writes the whole localdata to the server.
true.
Example
Failed to save order data.
toJSON()
Returns{ ...data, ...common, id }, which is what JSON.stringify(order) and console.log(order) print.
Types
OrderStatus
OrderInstance and OrderStatus are exported. OrderResponse is not; name it from Orders.updateStatus.
See also
Baskets— where orders come fromProducts— the catalog- Send proactive messages — notify the end user when a status changes
- Commerce REST API — orders over HTTP

