medusa-orders

Manage Medusa v2 orders — order lifecycle and state machine, fulfillment workflows, returns, exchanges, claims, draft orders, and order editing. Use when working with order processing.

17 stars

Best use case

medusa-orders is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Manage Medusa v2 orders — order lifecycle and state machine, fulfillment workflows, returns, exchanges, claims, draft orders, and order editing. Use when working with order processing.

Teams using medusa-orders should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/medusa-orders/SKILL.md --create-dirs "https://raw.githubusercontent.com/OrcaQubits/agentic-commerce-skills-plugins/main/dist/antigravity/medusa-commerce/.agent/skills/medusa-orders/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/medusa-orders/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How medusa-orders Compares

Feature / Agentmedusa-ordersStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Manage Medusa v2 orders — order lifecycle and state machine, fulfillment workflows, returns, exchanges, claims, draft orders, and order editing. Use when working with order processing.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Medusa v2 Order Management

## Before writing code

**Fetch live docs**:
1. Web-search `site:docs.medusajs.com order module` for order data model and service methods
2. Web-search `site:docs.medusajs.com order workflow fulfillment` for fulfillment workflow steps
3. Web-search `site:docs.medusajs.com return exchange claim` for return/exchange/claim flows
4. Fetch `https://docs.medusajs.com/resources/references/order` and review the `IOrderModuleService` interface
5. Web-search `medusajs v2 draft order editing 2026` for latest order editing workflows

## Order Lifecycle

### State Machine

```
PENDING ──> COMPLETED ──> FULFILLED ──> DELIVERED
    │           │              │
    └─ CANCELED └─ RETURNED    └─ PARTIALLY_RETURNED
```

### Order Statuses

| Status | Meaning |
|--------|---------|
| `pending` | Order created, awaiting payment |
| `completed` | Payment captured, order confirmed |
| `archived` | Order archived (no further action) |
| `canceled` | Order canceled before fulfillment |
| `requires_action` | Manual intervention needed |

### Fulfillment Status

| Status | Meaning |
|--------|---------|
| `not_fulfilled` | No items shipped |
| `partially_fulfilled` | Some items shipped |
| `fulfilled` | All items shipped |
| `shipped` / `delivered` | In transit / arrived |
| `partially_returned` / `returned` | Items returned |

### Payment Status

| Status | Meaning |
|--------|---------|
| `not_paid` / `awaiting` | No payment / pending auth |
| `authorized` | Payment authorized, not captured |
| `captured` | Full payment captured |
| `partially_refunded` / `refunded` | Refund issued |
| `canceled` | Payment voided |

## Order Module Architecture

```
Order Module ──link──> Payment Module (payment collections)
Order Module ──link──> Fulfillment Module (fulfillments)
Order Module ──link──> Product Module (line items)
Order Module ──link──> Customer Module (customer)
```

> **Fetch live docs** for exact link definitions and remote query patterns for cross-module order data.

## Key Service Methods

| Operation | Method | Notes |
|-----------|--------|-------|
| List orders | `orderModuleService.listOrders()` | Filters, pagination |
| Retrieve order | `orderModuleService.retrieveOrder()` | By ID with relations |
| Cancel order | via `cancelOrderWorkflow` | Workflow-managed |
| Archive order | via `archiveOrderWorkflow` | Workflow-managed |
| Complete order | via `completeOrderWorkflow` | After payment capture |

## Fulfillment Workflow

```
Order Confirmed ──> Create Fulfillment ──> Create Shipment ──> Delivered
```

| Workflow | Purpose |
|----------|---------|
| `createFulfillmentWorkflow` | Create fulfillment for order items |
| `cancelFulfillmentWorkflow` | Cancel a pending fulfillment |
| `createShipmentWorkflow` | Add tracking and mark as shipped |
| `markOrderFulfillmentAsDeliveredWorkflow` | Mark fulfillment as delivered |

> **Fetch live docs** for workflow input shapes -- fulfillment items, tracking numbers, and labels.

## Returns

```
Return Requested ──> Return Received ──> Refund Issued
       └─> Return Canceled      └─> Items Restocked
```

| Workflow | Purpose |
|----------|---------|
| `createReturnWorkflow` | Initiate return for order items |
| `confirmReturnReceiveWorkflow` | Mark return items as received |
| `cancelReturnWorkflow` | Cancel a return request |

Return reasons are configurable via the **Return Reason** entity (supports nesting via `parent_return_reason_id`).

## Exchanges and Claims

| Workflow | Purpose |
|----------|---------|
| `createExchangeWorkflow` | Initiate exchange (return + new items) |
| `cancelExchangeWorkflow` | Cancel pending exchange |
| `createClaimWorkflow` | Create claim for damaged/wrong items |
| `cancelClaimWorkflow` | Cancel a pending claim |

Exchanges combine return of original items with shipment of replacements, handling price differences automatically. Claims can result in refund, replacement, or both.

## Draft Orders

```ts
// Skeleton: create draft order
// Fetch live docs for createOrderWorkflow input shape
import { createOrderWorkflow } from "@medusajs/medusa/core-flows"

const { result } = await createOrderWorkflow(container)
  .run({ input: { /* order data */ } })
// Fetch live docs for CreateOrderWorkflowInput
```

## Order Editing

Modify orders after creation using the **Order Change** mechanism:

```
Begin Edit ──> Add/Remove Items ──> Confirm Edit ──> Payment Adjustment
```

### Order Change Actions

| Action | Description |
|--------|-------------|
| `ITEM_ADD` | Add a new line item |
| `ITEM_REMOVE` | Remove an existing line item |
| `ITEM_UPDATE` | Update line item quantity |
| `SHIPPING_ADD` / `SHIPPING_REMOVE` | Modify shipping methods |

> **Fetch live docs** for `orderEditAddItemWorkflow` and related edit workflows.

## Admin API Routes

| Route Pattern | Method | Purpose |
|---------------|--------|---------|
| `/admin/orders` | GET | List orders with filters |
| `/admin/orders/:id` | GET | Retrieve single order |
| `/admin/orders/:id/cancel` | POST | Cancel order |
| `/admin/orders/:id/fulfillments` | POST | Create fulfillment |
| `/admin/orders/:id/returns` | POST | Create return |
| `/admin/orders/:id/exchanges` | POST | Create exchange |
| `/admin/orders/:id/claims` | POST | Create claim |

> **Fetch live docs** for request body shapes and query parameters on each route.

## Best Practices

### Order Processing
- Always use **workflows** for order mutations -- they handle cross-module orchestration
- Check payment status before creating fulfillments
- Use order changes for post-creation modifications -- never mutate order data directly
- Implement idempotency keys for order creation to prevent duplicates

### Fulfillment
- Support **partial fulfillments** -- one order may ship from multiple locations
- Track fulfillment status through the state machine, not manual status sets
- Use `createShipmentWorkflow` to attach tracking info (not direct service calls)

### Returns and Exchanges
- Configure return reasons as a hierarchy (parent + child reasons) for analytics
- Exchanges automatically calculate price differences -- do not manually compute
- Claims should reference the original fulfillment for traceability

### Observability
- Subscribe to order events (`order.placed`, `order.completed`, `order.canceled`) for side effects
- Use subscribers for notifications, analytics, and third-party integrations

Fetch the Medusa v2 order module documentation and workflow references for exact service method signatures, workflow inputs, and state machine transitions before implementing.

Related Skills

ucp-orders-webhooks

17
from OrcaQubits/agentic-commerce-skills-plugins

Implement UCP Order capability and webhook delivery — post-purchase order management with fulfillment tracking, adjustments (refunds/returns), and cryptographically signed webhook notifications. Use when building order management or webhook infrastructure.

sf-orders

17
from OrcaQubits/agentic-commerce-skills-plugins

Manage Salesforce Commerce orders — B2C (SCAPI order objects, status lifecycle, order confirmation, returns) and B2B (Order object, OrderItem, splits, approval workflows, fulfillment). Use when implementing order management across either platform.

saleor-orders

17
from OrcaQubits/agentic-commerce-skills-plugins

Manage the Saleor order lifecycle — order creation, fulfillments, returns, refunds, draft orders, and order events. Use when working with Saleor orders.

medusa-workflows

17
from OrcaQubits/agentic-commerce-skills-plugins

Build Medusa v2 workflows — steps with createStep, compensation/rollback, parallel execution, hooks for extending built-in workflows, and when conditions. Use when orchestrating multi-step operations.

medusa-testing

17
from OrcaQubits/agentic-commerce-skills-plugins

Test Medusa v2 applications — Jest setup, module unit tests, workflow integration tests, API route tests, medusaIntegrationTestRunner, and mock patterns. Use when writing tests for Medusa projects.

medusa-subscribers

17
from OrcaQubits/agentic-commerce-skills-plugins

Implement Medusa v2 event subscribers — pub/sub event handling, subscriber handler functions, scheduled jobs with cron, and the event module (Redis or in-memory). Use when reacting to commerce events.

medusa-storefront

17
from OrcaQubits/agentic-commerce-skills-plugins

Build Medusa v2 storefronts with Next.js 15 — App Router, JS SDK client setup, Tanstack Query, server components, product pages, cart, and checkout flow. Use when developing headless storefronts.

medusa-setup

17
from OrcaQubits/agentic-commerce-skills-plugins

Set up a Medusa v2 development environment — CLI, PostgreSQL/Redis prerequisites, project creation, medusa-config.ts, directory structure, environment variables. Use when starting a new Medusa project.

medusa-security

17
from OrcaQubits/agentic-commerce-skills-plugins

Secure Medusa v2 applications — authentication strategies, API key types (publishable vs secret), CORS configuration, JWT and cookie secrets, admin vs store auth, and session management. Use when configuring security.

medusa-pricing

17
from OrcaQubits/agentic-commerce-skills-plugins

Configure Medusa v2 pricing — pricing module, price lists with rules, currencies, tax calculation, regions, and promotion campaigns. Use when setting up pricing and discounts.

medusa-plugins

17
from OrcaQubits/agentic-commerce-skills-plugins

Develop and publish Medusa v2 plugins — plugin structure, plugin vs module comparison, npm packaging, and reusable plugin template. Use when building distributable Medusa extensions.

medusa-payments

17
from OrcaQubits/agentic-commerce-skills-plugins

Implement Medusa v2 payment processing — payment module, provider abstraction, payment sessions, authorization/capture/refund lifecycle, and Stripe/PayPal integration. Use when adding payment providers.