Order Change

In this document, you'll learn what an order change is and the related concepts.

OrderChange Data Model#

The OrderChange data model represents any kind of change to an order, such as a return, exchange, or edit. Each of these is essentially an order change that is confirmed to apply changes to the original order.

The OrderChange model's change_type property indicates the purpose of the order change:

  1. edit: The order change is making edits to the order, as explained in the Order Edit guide.
  2. exchange: The order change is associated with an exchange, which you can learn about in the Order Exchange guide.
  3. claim: The order change is associated with a claim, which you can learn about in the Order Claim guide.
  4. return_request or return_receive: The order change is associated with a return, which you can learn about in the Order Return guide.

Once the order change is confirmed, its changes are applied to the order.


Order Change Actions#

The actions performed on the original order by an order change, such as adding an item, are represented by the OrderChangeAction data model.

The OrderChangeAction has an action property that indicates the type of action to perform on the order, and a details property that holds additional information related to the action.

The following table lists the possible action values that Medusa uses and the corresponding details they carry.

ActionDescriptionDetails

ITEM_ADD

Add an item to the order. The item is only added after the change is confirmed.

details is an object having the following properties:

  • reference_id: the ID of the new item.
  • quantity: The item's quantity.
  • unit_price: The item's unit price.
  • metadata: The item's metadata.

ITEM_UPDATE

Update an item in an order change. It's only applied to the order after the change is confirmed.

details is an object having the following properties:

  • reference_id: the ID of the item.
  • quantity: The item's quantity.
  • unit_price: The item's unit price.

ITEM_REMOVE

Remove an item from an order change. This can happen when a claim or an exchange is canceled.

details is an object having the following properties:

  • reference_id: the ID of the item.
  • quantity: The quantity to remove.

RETURN_ITEM

Set an item to be returned.

details is an object having the following properties:

  • reference_id: the ID of the item.
  • quantity: The quantity to be returned.
  • metadata: The item's metadata.

RECEIVE_RETURN_ITEM

Mark a return item as received.

details is an object having the following properties:

  • reference_id: the ID of the item.
  • quantity: The quantity received. This quantity is added to the inventory quantity of the item's variant when the return is confirmed.

RECEIVE_DAMAGED_RETURN_ITEM

Mark a return item that's damaged as received.

details is an object having the following properties:

  • reference_id: the ID of the item.
  • quantity: The quantity received. This quantity isn't added to the item variant's inventory quantity, as the quantity is damaged.

CANCEL_RETURN_ITEM

Cancel the return of an item. This can happen when a return is canceled.

details is an object having the following properties:

  • reference_id: the ID of the item.
  • quantity: The quantity to cancel.

SHIPPING_ADD

Add a shipping method to an order change. It's only added to the order after the change is confirmed.

No details added. The ID to the shipping method is added in the reference_id property of the action.

SHIPPING_REMOVE

Remove a shipping method from an order change. This can happen when a claim or an exchange is canceled.

No details added. The ID to the shipping method is added in the reference_id property of the action.

SHIP_ITEM

Mark an item's quantity as shipped.

details is an object having the following properties:

  • reference_id: the ID of the item.
  • quantity: The quantity to mark as shipped.
  • metadata: The item's metadata.

FULFILL_ITEM

Fulfill an item's quantity as part of a change.

details is an object having the following properties:

  • reference_id: the ID of the item.
  • quantity: The quantity to fulfill.
  • metadata: The item's metadata.

DELIVER_ITEM

Mark an item's quantity as delivered.

details is an object having the following properties:

  • reference_id: the ID of the item.
  • quantity: The quantity to mark as delivered.
  • metadata: The item's metadata.

WRITE_OFF_ITEM

Remove an item's quantity from an order change, without adding the quantity back to the item variant's inventory. The quantity isn't removed from the order until the change is confirmed.

details is an object having the following properties:

  • reference_id: the ID of the item.
  • quantity: The quantity to write off.
  • metadata: The item's metadata.

REINSTATE_ITEM

Reinstate an item's quantity in an order change that was previously written off. The quantity is added back to the item variant's inventory when the change is confirmed.

details is an object having the following properties:

  • reference_id: the ID of the item.
  • quantity: The quantity to reinstate.

TRANSFER_CUSTOMER

Transfer an order to another customer. The order is not removed from the original customer until the change is confirmed.

No details added. The ID to the new customer is added in the reference_id property of the action.

UPDATE_ORDER_PROPERTIES

Update the properties of an order, such as customer information or shipping address. The properties are not updated on the original order until the change is confirmed.

details is an object that has the properties to update. The properties are the same as the ones in the Order data model.

CREDIT_LINE_ADD

Add a credit line to an order. The credit line is not added to the original order until the change is confirmed.

No details added. The ID to the associated payment is added in the reference_id property of the action.

Was this page helpful?
Ask Anything
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break