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
addLineItem
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>Requiredcancel
Cancel an order edit.
Example
Parameters
id
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminOrderEditsRes>RequiredResolves to the order edit's details.
ResponsePromise
ResponsePromise<AdminOrderEditsRes>Requiredconfirm
Confirm an order edit. This will reflect the changes in the order edit on the associated order.
Example
Parameters
id
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminOrderEditsRes>RequiredResolves to the order edit's details.
ResponsePromise
ResponsePromise<AdminOrderEditsRes>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>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>RequireddeleteItemChange
Delete a line item change that indicates the addition, deletion, or update of a line item in the original order.
Example
Parameters
orderEditId
stringRequireditemChangeId
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminOrderEditItemChangeDeleteRes>RequiredResolves to the deletion operation's details.
ResponsePromise
ResponsePromise<AdminOrderEditItemChangeDeleteRes>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
query
GetOrderEditsParamsFilters and pagination configurations applied to retrieved order edits.
query
GetOrderEditsParamscustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminOrderEditsListRes>RequiredResolves to the list of order edits with pagination fields.
ResponsePromise
ResponsePromise<AdminOrderEditsListRes>RequiredremoveLineItem
Create a line item change in the order edit that indicates deleting an item in the original order. The item in the original order will not be deleted until the order edit is confirmed.
Example
Parameters
orderEditId
stringRequireditemId
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminOrderEditsRes>RequiredResolves to the order edit's details.
ResponsePromise
ResponsePromise<AdminOrderEditsRes>RequiredrequestConfirmation
Request customer confirmation of an order edit. This would emit the event order-edit.requested
which Notification Providers listen to and send
a notification to the customer about the order edit.
Example
Parameters
id
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminOrderEditsRes>RequiredResolves to the order edit's details.
ResponsePromise
ResponsePromise<AdminOrderEditsRes>Requiredretrieve
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
stringRequiredConfigurations to apply on the retrieved order edit.
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>RequiredupdateLineItem
Create or update a line item change in the order edit that indicates addition, deletion, or update of a line item into an original order. Line item changes are only reflected on the original order after the order edit is confirmed.
Example
Parameters
orderEditId
stringRequireditemId
stringRequiredThe creation or update of the line item change.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminOrderEditsRes>RequiredResolves to the order edit's details.
ResponsePromise
ResponsePromise<AdminOrderEditsRes>Required