Order changes
Amendments to a placed order, proposed and confirmed as a unit, with a version per confirmed change.
An order change is a set of edits to a placed order, proposed together and confirmed as one. Each confirmed change writes a new version of the order, so what the customer agreed to at each point stays readable. Order versioning is a storage feature and is switched on per store. See Order changes.
List an order's changes
/api/v1/kahunacart/orders/{id}/changes
Every change ever staged against an order, newest first, each with its typed actions, its state (staged, confirmed or discarded) and the versions it moved the order between. Also answers the order's current version, whether the order is locked (closed, and needing unlock_order before it can be changed), and the action vocabulary each kind of change may use.
Parameters
| Name | Type | Description |
|---|---|---|
| id required | integer | Order id |
Stage a change to an order
/api/v1/kahunacart/orders/{id}/changes
Open a change against a placed order. Nothing is written to the order by this call or by any action added to it — the change is a proposal until confirm_order_change is called, and a change that is never confirmed leaves the order exactly as it was. Add actions with add_order_change_action, read the previewed totals it returns, then confirm. Refused with 409 for a cart (use the cart endpoints), for a closed order that has not been unlocked, and when this store has not switched on order versioning. Pass idempotency_key to make a retried request answer with the change it already opened.
Parameters
| Name | Type | Description |
|---|---|---|
| id required | integer | Order id |
| change_type optional | string |
What this change is about. Decides which actions are legal inside it.
One of:
edit, exchange, claim, return_request, return_receiveDefault:
edit |
| reason optional | string | Why. Recorded on the order's history when confirmed. |
| idempotency_key optional | string | A retried request with the same key answers with the same change |
Add an action to a staged change
/api/v1/kahunacart/orders/{id}/changes/{cid}/actions
Add one typed verb to a staged change and get back the previewed totals. Still writes nothing to the order. The vocabulary is add_item, write_off_item, reinstate_item, update_quantity, update_price, add_adjustment, remove_adjustment, update_shipping, update_address, update_tax, add_payment, refund_payment and return_item — and which of them a change may use depends on its change_type, which list_order_changes reports. There is no delete_item, and that is on purpose: removing a line is write_off_item, which leaves the original line readable forever at the version it was bought under. Every amount is in minor units of the order's own currency. On a store that sells in more than one currency, an add_item that names a variant_id and sends no unit_price_minor is priced at that variant's price in the order's currency, and a variant with no price in it is refused with 422 whatever price is sent. An add_item with no variant_id is a custom line, priced by the amount you send.
Parameters
| Name | Type | Description |
|---|---|---|
| id required | integer | Order id |
| cid required | integer | Change id |
| action required | string |
One of:
add_item, write_off_item, reinstate_item, update_quantity, update_price, add_adjustment, remove_adjustment, update_shipping, update_address, update_tax, add_payment, refund_payment, return_item |
| item_id optional | integer | The order line this acts on, where the verb names one |
| adjustment_id optional | integer | For remove_adjustment |
| variant_id optional | integer | For add_item, and for a return whose line has no variant. On a store that sells in more than one currency an add_item with a variant is priced in the order's currency |
| qty optional | integer | For add_item and update_quantity |
| received_qty optional | integer | Returns: how many units actually turned up |
| damaged_qty optional | integer | Returns: how many of those are damaged. Damaged units never go back into stock. |
| unit_price_minor optional | integer | Minor units of the order's currency. For add_item and update_price. |
| amount_minor optional | integer | Minor units of the order's currency. For the adjustment, shipping, tax, payment and refund verbs. |
| title optional | string | For add_item |
| label optional | string | For the adjustment, shipping and tax verbs |
| type optional | string | For add_adjustment: discount, shipping, tax or fee. Defaults to fee. |
| basis optional | string |
For update_address
One of:
billing, shipping |
Confirm a staged change
/api/v1/kahunacart/orders/{id}/changes/{cid}/confirm
Apply the change to a new version of the order, atomically. The order's version is incremented, every current line and adjustment is duplicated into the new version, the actions are applied to the copies, and the previous version's rows are left exactly as they were and stay readable forever through get_order_version. Recalculation appends and never removes. A return_receive change puts the sound units back on the shelf and leaves the damaged ones off it. Idempotent: a repeated confirm answers with applied: false and changes nothing.
Parameters
| Name | Type | Description |
|---|---|---|
| id required | integer | Order id |
| cid required | integer | Change id |
Discard a staged change
/api/v1/kahunacart/orders/{id}/changes/{cid}/cancel
Abandon a staged change. Its actions stay on the record, because a proposal that was withdrawn is still worth being able to read later. Refused with 409 for a change that has already been confirmed.
Parameters
| Name | Type | Description |
|---|---|---|
| id required | integer | Order id |
| cid required | integer | Change id |
Read an order at one version
/api/v1/kahunacart/orders/{id}/versions/{v}
The lines and adjustments an order carried at a given version, exactly as they were written. Version 1 is the order as it was placed and reads back unchanged however many times it has been edited since — including the lines a later change wrote off, which is what makes an edit safe.
Parameters
| Name | Type | Description |
|---|---|---|
| id required | integer | Order id |
| v required | integer | Version number, starting at 1 |
Unlock a closed order for editing
/api/v1/kahunacart/orders/{id}/unlock
Open an order whose status is marked final — cancelled, archived, or anything a merchant flagged that way — so a change can be staged against it. Never refused, and never silent: the unlock writes an entry on the order's history naming whoever asked for it. This is not an editing cliff; it is one audited action.
Parameters
| Name | Type | Description |
|---|---|---|
| id required | integer | Order id |
| reason optional | string | Recorded on the order's history |
Mark an order as a test order
/api/v1/kahunacart/orders/{id}/test
Mark an order the merchant placed to try the store (a rehearsal, a comp, a card run through a live provider) as a test order, or with test false take the mark off. A test order is left out of every report, its refunds included, and stays an order in every other way. Recorded on the order's history. Answers changed false when the order already stood that way.
Parameters
| Name | Type | Description |
|---|---|---|
| id required | integer | Order id |
| test optional | boolean |
true marks it a test order, false counts it again
Default:
true |
| reason optional | string | Recorded on the order's history |
Set how an order's dispute stands
/api/v1/kahunacart/orders/{id}/dispute
Set an order's dispute to won, lost, or back to open, by hand. For a platform that does not report how a dispute ended (Paddle, Mollie), or to put right one that was reported wrong; Stripe and PayPal settle it on their own. Recorded on the order's history as the person's, and the order list's dispute badge and the open-disputes alert follow it. Answers changed false when the order already stood that way.
Parameters
| Name | Type | Description |
|---|---|---|
| id required | integer | Order id |
| outcome required | string |
won: the store keeps the money; lost: it went back to the customer; open: not settled yet
One of:
open, won, lost |
| note optional | string | Recorded on the order's history |
A change is built in three steps: open it, add one or more actions to it, then confirm or cancel. Nothing on the order moves until confirm. unlock releases an order another admin left locked while editing.