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
idstringRequiredcustomHeadersRecord<string, any>RequiredDefault: {}
Configurations to apply on the retrieved order edit.
Returns
ResponsePromiseResponsePromise<AdminOrderEditsRes>RequiredResolves to the order edit's details.
ResponsePromiseResponsePromise<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
customHeadersRecord<string, any>RequiredDefault: {}
queryGetOrderEditsParamsFilters and pagination configurations applied to retrieved order edits.
queryGetOrderEditsParamsReturns
ResponsePromiseResponsePromise<AdminOrderEditsListRes>RequiredResolves to the list of order edits with pagination fields.
ResponsePromiseResponsePromise<AdminOrderEditsListRes>Requiredcreate
Create an order edit.
Example
Parameters
The order edit to create.
customHeadersRecord<string, any>RequiredDefault: {}
Returns
ResponsePromiseResponsePromise<AdminOrderEditsRes>RequiredResolves to the order edit's details.
ResponsePromiseResponsePromise<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
idstringRequiredThe attributes to update in an order edit.
customHeadersRecord<string, any>RequiredDefault: {}
Returns
ResponsePromiseResponsePromise<AdminOrderEditsRes>RequiredResolves to the order edit's details.
ResponsePromiseResponsePromise<AdminOrderEditsRes>Requireddelete
Delete an order edit. Only order edits that have the status created can be deleted.
Example
Parameters
idstringRequiredcustomHeadersRecord<string, any>RequiredDefault: {}
Returns
ResponsePromiseResponsePromise<DeleteResponse>RequiredResolves to the deletion operation's details.
ResponsePromiseResponsePromise<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
idstringRequiredThe line item change to be created.
customHeadersRecord<string, any>RequiredDefault: {}
Returns
ResponsePromiseResponsePromise<AdminOrderEditsRes>RequiredResolves to the order edit's details.
ResponsePromiseResponsePromise<AdminOrderEditsRes>RequireddeleteItemChange
Delete a line item change that indicates the addition, deletion, or update of a line item in the original order.
Example
Parameters
orderEditIdstringRequireditemChangeIdstringRequiredcustomHeadersRecord<string, any>RequiredDefault: {}
Returns
ResponsePromiseResponsePromise<AdminOrderEditItemChangeDeleteRes>RequiredResolves to the deletion operation's details.
ResponsePromiseResponsePromise<AdminOrderEditItemChangeDeleteRes>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
idstringRequiredcustomHeadersRecord<string, any>RequiredDefault: {}
Returns
ResponsePromiseResponsePromise<AdminOrderEditsRes>RequiredResolves to the order edit's details.
ResponsePromiseResponsePromise<AdminOrderEditsRes>Requiredcancel
Cancel an order edit.
Example
Parameters
idstringRequiredcustomHeadersRecord<string, any>RequiredDefault: {}
Returns
ResponsePromiseResponsePromise<AdminOrderEditsRes>RequiredResolves to the order edit's details.
ResponsePromiseResponsePromise<AdminOrderEditsRes>Requiredconfirm
Confirm an order edit. This will reflect the changes in the order edit on the associated order.
Example
Parameters
idstringRequiredcustomHeadersRecord<string, any>RequiredDefault: {}
Returns
ResponsePromiseResponsePromise<AdminOrderEditsRes>RequiredResolves to the order edit's details.
ResponsePromiseResponsePromise<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
orderEditIdstringRequireditemIdstringRequiredThe creation or update of the line item change.
customHeadersRecord<string, any>RequiredDefault: {}
Returns
ResponsePromiseResponsePromise<AdminOrderEditsRes>RequiredResolves to the order edit's details.
ResponsePromiseResponsePromise<AdminOrderEditsRes>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
orderEditIdstringRequireditemIdstringRequiredcustomHeadersRecord<string, any>RequiredDefault: {}
Returns
ResponsePromiseResponsePromise<AdminOrderEditsRes>RequiredResolves to the order edit's details.
ResponsePromiseResponsePromise<AdminOrderEditsRes>Required