Skip to main content
Skip to main content

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

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.addLineItem(orderEditId, {
variant_id,
quantity
})
.then(({ order_edit }) => {
console.log(order_edit.id)
})

Parameters

idstringRequired
The ID of the order edit to add the line item change to.
The line item change to be created.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminOrderEditsRes>Required
Resolves to the order edit's details.

cancel

Cancel an order edit.

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.cancel(orderEditId)
.then(({ order_edit }) => {
console.log(order_edit.id)
})

Parameters

idstringRequired
The ID of the order edit to cancel.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminOrderEditsRes>Required
Resolves to the order edit's details.

confirm

Confirm an order edit. This will reflect the changes in the order edit on the associated order.

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.confirm(orderEditId)
.then(({ order_edit }) => {
console.log(order_edit.id)
})

Parameters

idstringRequired
The ID of the order edit to confirm.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminOrderEditsRes>Required
Resolves to the order edit's details.

create

Create an order edit.

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.create({ orderId })
.then(({ order_edit }) => {
console.log(order_edit.id)
})

Parameters

payloadAdminPostOrderEditsReqRequired
The order edit to create.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminOrderEditsRes>Required
Resolves to the order edit's details.

delete

Delete an order edit. Only order edits that have the status created can be deleted.

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.delete(orderEditId)
.then(({ id, object, deleted }) => {
console.log(id)
})

Parameters

idstringRequired
The ID of the order edit.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<DeleteResponse>Required
Resolves to the deletion operation's details.

deleteItemChange

Delete a line item change that indicates the addition, deletion, or update of a line item in the original order.

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.deleteItemChange(orderEdit_id, itemChangeId)
.then(({ id, object, deleted }) => {
console.log(id)
})

Parameters

orderEditIdstringRequired
The ID of the order edit.
itemChangeIdstringRequired
The ID of the line item change.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminOrderEditItemChangeDeleteRes>Required
Resolves to the deletion operation's details.

list

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:

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()
.then(({ order_edits, count, limit, offset }) => {
console.log(order_edits.length)
})

To specify relations that should be retrieved within the order edits:

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"
})
.then(({ order_edits, count, limit, offset }) => {
console.log(order_edits.length)
})

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

Filters and pagination configurations applied to retrieved order edits.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminOrderEditsListRes>Required
Resolves to the list of order edits with pagination fields.

removeLineItem

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

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.removeLineItem(orderEditId, lineItemId)
.then(({ order_edit }) => {
console.log(order_edit.id)
})

Parameters

orderEditIdstringRequired
The ID of the order edit that the line item change belongs to.
itemIdstringRequired
The ID of the line item.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminOrderEditsRes>Required
Resolves to the order edit's details.

requestConfirmation

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

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.requestConfirmation(orderEditId)
.then({ order_edit }) => {
console.log(order_edit.id)
})

Parameters

idstringRequired
The ID of the order edit.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminOrderEditsRes>Required
Resolves to the order edit's details.

retrieve

Retrieve an order edit's details.

Example

A simple example that retrieves an order edit by its ID:

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.retrieve(orderEditId)
.then(({ order_edit }) => {
console.log(order_edit.id)
})

To specify relations that should be retrieved:

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.retrieve(orderEditId, {
expand: "order"
})
.then(({ order_edit }) => {
console.log(order_edit.id)
})

Parameters

idstringRequired
The ID of the order edit.
Configurations to apply on the retrieved order edit.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminOrderEditsRes>Required
Resolves to the order edit's details.

update

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

idstringRequired
The ID of the order edit.
The attributes to update in an order edit.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminOrderEditsRes>Required
Resolves to the order edit's details.

updateLineItem

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

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.updateLineItem(orderEditId, lineItemId, {
quantity: 5
})
.then(({ order_edit }) => {
console.log(order_edit.id)
})

Parameters

orderEditIdstringRequired
The ID of the order edit that the line item belongs to.
itemIdstringRequired
The ID of the line item to create or update its line item change.
The creation or update of the line item change.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminOrderEditsRes>Required
Resolves to the order edit's details.
Was this section helpful?