Skip to main content

Overview

The Order Module manages the complete order lifecycle including order creation, modifications, fulfillment tracking, returns, claims, and exchanges. It provides versioning support for order changes and maintains detailed transaction history. Key Features:
  • Order management with status tracking
  • Order versioning for change history
  • Line items with tax lines and adjustments
  • Shipping methods with tax and adjustments
  • Returns, claims, and exchanges
  • Order changes with approval workflow
  • Transaction tracking
  • Credit lines for store credit

When to Use

Use the Order Module when you need to:
  • Create orders from completed carts
  • Track order status and fulfillment
  • Handle order modifications and cancellations
  • Process customer returns
  • Manage product claims and replacements
  • Handle order exchanges
  • Apply discounts and promotions to orders
  • Track payment transactions

Data Models

Order

The core order entity representing a customer purchase.
string
required
Unique order identifier (prefix: order_)
number
required
Auto-incrementing display ID for customer reference
string
Custom display ID (e.g., “ORD-2024-001”)
OrderStatus
required
Order status: pending, completed, archived, canceled
number
required
Order version number (increments with changes)
string
ID of the customer who placed the order
string
Customer email address
string
required
Three-letter ISO currency code
string
ID of the associated region
string
ID of the sales channel where order was placed
boolean
Whether this is a draft order (default: false)
OrderItem[]
Order line items
OrderAddress
Shipping address for the order
OrderAddress
Billing address for the order
OrderShippingMethod[]
Shipping methods applied to the order
OrderTransaction[]
Payment transactions
OrderSummary[]
Order totals summary by version
Return[]
Returns associated with this order

OrderItem

Represents a line item in an order.
string
required
Unique item identifier
string
required
ID of the parent order
number
required
Order version when item was added
string
required
Reference to the cart line item
string
ID of the product
string
ID of the product variant
number
required
Item quantity
BigNumber
required
Price per unit
OrderLineItem
Detailed line item information including totals

OrderLineItem

Detailed line item with pricing and tax information.
string
required
Unique line item identifier
string
required
Line item title
string
Line item subtitle
string
Product thumbnail URL
number
required
Item quantity
BigNumber
required
Price per unit before discounts
OrderLineItemTaxLine[]
Tax lines applied to this item
OrderLineItemAdjustment[]
Discount adjustments applied to this item

OrderChange

Tracks modifications to an order.
string
required
Unique change identifier
string
required
ID of the order being changed
number
required
Order version this change applies to
string
Type of change: return, exchange, claim, edit
OrderChangeStatus
required
Change status: pending, requested, confirmed, declined, canceled
string
User ID who requested the change
string
User ID who confirmed the change
OrderChangeAction[]
Individual actions in this change

Return

Represents a product return.
string
required
Unique return identifier (prefix: return_)
string
required
ID of the order being returned
string
Return status
ReturnItem[]
Items being returned
string
Stock location where items will be returned

OrderClaim

Represents a customer claim for damaged or incorrect items.
string
required
Unique claim identifier
string
required
ID of the order being claimed
OrderClaimItem[]
Items being claimed

OrderExchange

Represents an item exchange.
string
required
Unique exchange identifier
string
required
ID of the order
OrderExchangeItem[]
Items being exchanged

Service Interface

The Order Module service is available at @medusajs/medusa/order.

Retrieve Order

Retrieve a single order with related data.
string
required
The ID of the order to retrieve
FindConfig
Configuration for the query
string[]
Relations to load (e.g., ["items", "shipping_address"])
string[]
Fields to select from the order
OrderDTO
The retrieved order

List Orders

List orders with filtering and pagination.
FilterableOrderProps
Filters to apply
string | string[]
Filter by order IDs
OrderStatus[]
Filter by order status
string | string[]
Filter by customer IDs
string | string[]
Filter by sales channel IDs
string
Filter by customer email
OrderDTO[]
Array of orders matching the filters
number
Total count of matching orders

Create Orders

Create one or more orders (typically from a cart).
CreateOrderDTO | CreateOrderDTO[]
required
Order data to create
string
ID of the customer
string
Customer email
string
required
Three-letter ISO currency code
string
ID of the region
CreateOrderLineItemDTO[]
Order line items
CreateOrderAddressDTO
Shipping address
CreateOrderAddressDTO
Billing address
OrderDTO | OrderDTO[]
The created order(s)

Update Orders

Update order information.

Create Order Change

Initiate a change to an order.
CreateOrderChangeDTO
required
Order change data
string
required
ID of the order to change
string
Type of change: return, exchange, claim, edit
string
User ID who requested the change
OrderChangeActionDTO[]
Individual actions in this change

Confirm Order Change

Confirm and apply an order change.

Create Return

Create a product return.
CreateReturnDTO | CreateReturnDTO[]
required
Return data
string
required
ID of the order
CreateReturnItemDTO[]
required
Items to return
string
Stock location for return

Create Order Claim

Create a claim for damaged or incorrect items.

Create Order Exchange

Create an item exchange.

Integration Examples

With Cart Module

Orders are typically created from completed carts.

With Payment Module

Track payment transactions for orders.

With Fulfillment Module

Create fulfillments for order items.

Best Practices

  1. Order Versioning: The order version increments with each modification. Always reference the version when making changes.
  2. Order Changes: Use the OrderChange entity for tracking modifications. This provides an audit trail and approval workflow.
  3. Status Management: Follow the order status flow: pendingcompletedarchived. Use canceled for cancelled orders.
  4. Transaction Tracking: Create OrderTransaction entries for all payment-related activities to maintain a complete financial record.
  5. Returns and Exchanges: Use dedicated return and exchange entities rather than modifying the original order.
  6. Display IDs: Use display_id for customer-facing order numbers. Optionally set custom_display_id for custom formatting.