npm.io
2.22.7 • Published 4d ago

@medusajs/order

Licence
MIT
Version
2.22.7
Deps
0
Size
828 kB
Vulns
0
Weekly
0
Stars
36.5K

Medusa logo

@medusajs/order

Documentation | Website

Building blocks for digital commerce

Medusa is released under the MIT license. PRs welcome! Discord Chat Follow @medusajs

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)
  }
)

Resources