AdminOrderEditsResource
This class is used to send requests to Admin Order Edit API Routes. All its method
are available in the JS Client under the medusa.admin.orderEdits
property.
All methods in this class require user authentication.
An admin can edit an order to remove, add, or update an item's quantity. When an admin edits an order, they're stored as an OrderEdit
.
Related Guide: How to edit an order.
Methods
retrieve
Retrieve an order edit's details.
Example
A simple example that retrieves an order edit by its ID:
To specify relations that should be retrieved:
Parameters
id
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Configurations to apply on the retrieved order edit.
Returns
ResponsePromise
ResponsePromise<AdminOrderEditsRes>RequiredResolves to the order edit's details.
ResponsePromise
ResponsePromise<AdminOrderEditsRes>Requiredlist
Retrieve a list of order edits. The order edits can be filtered by fields such as q
or order_id
passed to the query
parameter. The order edits can also be paginated.
Example
To list order edits:
To specify relations that should be retrieved within the order edits:
By default, only the first 50
records are retrieved. You can control pagination by specifying the limit
and offset
properties:
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.list({
expand: "order",
limit,
offset
})
.then(({ order_edits, count, limit, offset }) => {
console.log(order_edits.length)
})
Parameters
customHeaders
Record<string, any>RequiredDefault: {}
query
GetOrderEditsParamsFilters and pagination configurations applied to retrieved order edits.
query
GetOrderEditsParamsReturns
ResponsePromise
ResponsePromise<AdminOrderEditsListRes>RequiredResolves to the list of order edits with pagination fields.
ResponsePromise
ResponsePromise<AdminOrderEditsListRes>Requiredcreate
Create an order edit.
Example
Parameters
The order edit to create.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminOrderEditsRes>RequiredResolves to the order edit's details.
ResponsePromise
ResponsePromise<AdminOrderEditsRes>Requiredupdate
Update an Order Edit's details.
Example
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.update(orderEditId, {
internal_note: "internal reason XY"
})
.then(({ order_edit }) => {
console.log(order_edit.id)
})
Parameters
id
stringRequiredThe attributes to update in an order edit.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminOrderEditsRes>RequiredResolves to the order edit's details.
ResponsePromise
ResponsePromise<AdminOrderEditsRes>Requireddelete
Delete an order edit. Only order edits that have the status created
can be deleted.
Example
Parameters
id
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<DeleteResponse>RequiredResolves to the deletion operation's details.
ResponsePromise
ResponsePromise<DeleteResponse>RequiredaddLineItem
Create a line item change in the order edit that indicates adding an item in the original order. The item will not be added to the original order until the order edit is confirmed.
Example
Parameters
id
stringRequiredThe line item change to be created.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminOrderEditsRes>RequiredResolves to the order edit's details.
ResponsePromise
ResponsePromise<AdminOrderEditsRes>RequireddeleteItemChange
Delete a line item change that indicates the addition, deletion, or update of a line item in the original order.