Skip to main content
Skip to main content

Order Edits

Queries and Mutations listed here are used to send requests to the Store Order Edits API Routes.

Order edits are changes made to items in an order such as adding, updating their quantity, or deleting them. Order edits are created by the admin. A customer can review order edit requests created by an admin and confirm or decline them.

Related Guide: How to handle order edits in a storefront.

Mutations

useDeclineOrderEdit

This hook declines an Order Edit. The changes are not reflected on the original order.

Example

import React from "react"
import { useDeclineOrderEdit } from "medusa-react"

type Props = {
orderEditId: string
}

const OrderEdit = ({ orderEditId }: Props) => {
const declineOrderEdit = useDeclineOrderEdit(orderEditId)
// ...

const handleDeclineOrderEdit = (
declinedReason: string
) => {
declineOrderEdit.mutate({
declined_reason: declinedReason,
}, {
onSuccess: ({ order_edit }) => {
console.log(order_edit.declined_at)
}
})
}

// ...
}

export default OrderEdit

Hook Parameters

idstringRequired
The order edit's ID.

Mutation Function Parameters

StorePostOrderEditsOrderEditDeclineStorePostOrderEditsOrderEditDeclineRequired
The details of the order edit's decline.

Mutation Function Returned Data

StoreOrderEditsResStoreOrderEditsResRequired
The order edit's details.

useCompleteOrderEdit

This hook completes and confirms an Order Edit and reflect its changes on the original order. Any additional payment required must be authorized first using the useAuthorizePaymentSession hook.

Example

import React from "react"
import { useCompleteOrderEdit } from "medusa-react"

type Props = {
orderEditId: string
}

const OrderEdit = ({ orderEditId }: Props) => {
const completeOrderEdit = useCompleteOrderEdit(
orderEditId
)
// ...

const handleCompleteOrderEdit = () => {
completeOrderEdit.mutate(void 0, {
onSuccess: ({ order_edit }) => {
console.log(order_edit.confirmed_at)
}
})
}

// ...
}

export default OrderEdit

Hook Parameters

idstringRequired
The order edit's ID.

Mutation Function Returned Data

StoreOrderEditsResStoreOrderEditsResRequired
The order edit's details.

Queries

useOrderEdit

This hook retrieves an Order Edit's details.

Example

import React from "react"
import { useOrderEdit } from "medusa-react"

type Props = {
orderEditId: string
}

const OrderEdit = ({ orderEditId }: Props) => {
const { order_edit, isLoading } = useOrderEdit(orderEditId)

return (
<div>
{isLoading && <span>Loading...</span>}
{order_edit && (
<ul>
{order_edit.changes.map((change) => (
<li key={change.id}>{change.type}</li>
))}
</ul>
)}
</div>
)
}

export default OrderEdit

Hook Parameters

idstringRequired
The order edit's ID.

Query Returned Data

order_editOmit<OrderEdit, "internal_note" | "created_by" | "confirmed_by" | "canceled_by">Required
Order edit details.
Was this section helpful?