Overview
An order is a placed purchase. It’s created by completing a Cart and holds its own copy of everything the customer agreed to — items, prices, taxes, discounts and delivery. Anything your storefront stored in the cart’smetadata is copied onto the order too, including onto every order of a checkout split between sellers.
Order attributes
Every amount comes in two forms:
total is the raw value ("135.60") and display_total is formatted for the currency ("$135.60"). Render the display_ one.
Statuses
An order tracks payment and delivery separately, because they genuinely move at different speeds. An order can be paid but not yet sent, or sent and later partly refunded.payment_status
fulfillment_status
A canceled parcel is ignored while others are still live, so an order whose
second parcel was recalled is described by the first.
delivered means every parcel arrived. A fulfillment that travels as several
consignments — a machine in three boxes, a pallet under one freight number —
is only delivered when the last of them lands, and the order follows from
there. See where the parcel actually
is.
Both are worked out automatically from the order’s payments, refunds and fulfillments. You change an order’s status by acting on those — taking a payment, sending a parcel, issuing a refund — never by setting the status yourself.
Reading an order
A customer can fetch their own order; guests use the order token they got at checkout.Managing orders
Back-office work happens through the Admin API.refund_amount names part of that share to return, keeping a restocking fee
back, say. It is refused on an ordinary order rather than ignored: the gateway
returns the whole captured payment there, so a cap could not be honoured, and
accepting one would refund everything while you believed part was held back.
It records who canceled, and optionally why: the reason comes from a list you
manage yourself under Settings, so it can say what your team actually means. A
staff-facing note can go alongside it.
Orders don’t change quietly
A placed order is meant to stay put. Its items and prices are written when the cart is completed and then left alone, so an order keeps saying what the customer actually agreed to — even if a product’s price changes the next day. Where admin edits are allowed, totals are re-added from the order’s existing rows rather than worked out again from scratch. Editing an order must never quietly re-apply today’s promotions and hand the customer a different discount than the one they accepted.Editing a placed order
Changes to a placed order’s items go through an order change: a set of actions — add a product, change a quantity, remove a line — that is previewed first and then applied in one go. Either every action applies or none does, and each applied change stays on the order as a record of who changed what, and when. Preview a change to see what it does to the totals before anything is saved, then create it withconfirm: true to apply it. This is what the admin
dashboard’s Edit order screen does on a placed order.
- Admin SDK
- cURL
- No money moves on its own. Applying a change updates the order’s totals
and its payment status —
partially_paidwhen the customer owes more,overchargedwhen they are owed some back. You collect or refund the difference from the order’s payments, as after any other edit. - One change at a time. Created without
confirm, a change waits asrequesteduntil it is confirmed or canceled, and the order takes no other change in the meantime. - Stock is taken when the change is applied, not while it waits. An added product that sold out in between makes the change fail, with nothing applied.
- A line keeps the price it was sold at. Changing a quantity never re-prices the line.
- Drafts are edited directly through the order. Order changes are for placed orders only.
add_discount (label, value, optional value_type and
line_item_id), update_discount (discount_id with a new label or
amount) and remove_discount (discount_id); discounts apply after the item
edits, so an order-level discount is spread over the lines the change leaves.
The order discounts endpoints do the same on a placed
order, one discount per change. Discounts from promotions are read-only.
Updating a placed order’s items through PATCH /api/v3/admin/orders/{id} is
an order change as well: each item becomes an add_item, update_item or
remove_item action, applied at once. A price can’t be set on a placed
order’s items.
Returns, exchanges and claims use the same mechanism: receiving goods back and
shipping replacements each leave an order change on the order, linked to the
return, exchange or claim that made it.
To refuse some edits — after a cut-off time, or for products that cannot be
added after placement — register a handler on the order_changes.add_action.validate
hook. order_changes.confirm.before_confirm runs once a change is applied but
before it is committed, and can still refuse it (see Workflows).
To settle the balance automatically — charging or refunding at your payment
provider — subscribe to the order_change.confirmed event,
which is sent once the change is saved, rather than doing it in a hook: a
return or claim can apply its change inside a larger step that may still fail.
The event’s balance_delta is how far the change moved the order total, and
previous_total and new_total are the totals on either side of it.
config/initializers/spree.rb
Money on an order
Tax, discounts and fees are kept as separate records, so you can ask what tax was charged without picking through a mixed list. See Order totals.Events
Orders publish events —order.placed, order.canceled, order.paid and more — which also reach webhooks. This is the right way to push orders to another system, trigger fulfillment, or start an email flow.
Related
- Carts — shopping and checkout
- Fulfillments — getting items to the customer
- Returns, Exchanges & Claims — after the sale
- Payments — payment methods and processing

