@medusajs/order
Documentation | Website
Building blocks for digital commerce
Order Module for Medusa: manages orders, line items, shipping methods, addresses, returns, claims, exchanges, order changes, transactions, and credit lines. Use it to store placed and draft orders and handle post-purchase flows such as returns, exchanges, and order edits. It ships with @medusajs/medusa and is registered by default, so Medusa applications don't install it directly.
At a glance
| Package | @medusajs/order |
| Type | Commerce Module |
| Module key | Modules.ORDER ("order") |
| Registered by default | Yes |
| Import from | @medusajs/medusa/order |
Features
- Store orders with line items, shipping methods, addresses, adjustments, and tax lines.
- Handle returns, claims, and exchanges, with return reasons.
- Track order changes and versions for edits and other post-purchase actions.
- Record payment transactions and credit lines on an order.
Installation
No installation needed. The module is included in @medusajs/medusa and registered by default.
Usage
Resolve the module's service from the container, for example in a workflow step:
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
import { Modules } from "@medusajs/framework/utils"
const createDraftOrderStep = createStep(
"create-order",
async ({}, { container }) => {
const orderModuleService = container.resolve(Modules.ORDER)
const draftOrder = await orderModuleService.createOrders({
currency_code: "usd",
items: [
{
title: "Shirt",
quantity: 1,
unit_price: 30,
},
],
status: "draft",
})
return new StepResponse({ draftOrder }, draftOrder.id)
}
)