Skip to main content

Documentation Index

Fetch the complete documentation index at: https://86d.app/docs/llms.txt

Use this file to discover all available pages before exploring further.

The orders module handles every stage of an order’s life, from the moment it is created through fulfillment, returns, and invoicing. Customers can view their order history, cancel eligible orders, track shipments, and submit return requests directly from your storefront. All store endpoints require an authenticated session, and each endpoint verifies that the order belongs to the requesting customer before returning any data. Source: modules/orders · npm: @86d-app/orders

Installation

npm install @86d-app/orders

Configuration

import orders from "@86d-app/orders";
import { createModuleClient } from "@86d-app/core";

const client = createModuleClient([
  orders({
    currency: "USD",
  }),
]);
currency
string
default:"\"USD\""
Default currency code applied to new orders. Individual orders can override this when calling controller.create().

Store endpoints

All store endpoints require an authenticated session. Requests for orders that do not belong to the authenticated customer return 404 (not 403), to avoid leaking the existence of other customers’ orders.
MethodPathDescription
GET/orders/meList all orders for the authenticated customer
GET/orders/me/:idGet a specific order with items and addresses
POST/orders/me/:id/cancelCancel a pending, processing, or on-hold order
GET/orders/me/:id/fulfillmentsList fulfillments and overall fulfillment status
GET/orders/me/:id/invoiceGet invoice data for an order
GET/orders/me/:id/returnsList return requests for an order
POST/orders/me/:id/returns/createSubmit a return request
GET/orders/me/returnsList all returns across all of the customer’s orders
POST/orders/me/:id/reorderGet cart-ready items from a previous order
POST/orders/trackGuest order tracking (order number + email, no auth required)
POST /orders/me/:id/reorder returns line items ready to be added back to the cart. It does not create a cart or modify any existing cart automatically.

Status flows

Order status:
  pending → processing → on_hold → completed
                                  ↘ cancelled
                                  ↘ refunded

Payment status:
  unpaid → paid → partially_paid → refunded
                ↘ voided

Return status:
  requested → approved → shipped_back → received → refunded → completed
            → rejected

Fulfillment status:
  unfulfilled | partially_fulfilled | fulfilled
An order can only be cancelled when its status is pending, processing, or on_hold. Orders in completed, cancelled, or refunded states cannot be cancelled. Order numbers are auto-generated in the format ORD-{base36timestamp}-{random}. Invoice numbers follow INV-{YYYYMMDD}-{orderSuffix}.

Events

The module emits the following events that you can subscribe to in other modules or webhooks:
EventTrigger
order.placedOrder created
order.updatedOrder metadata changed
order.fulfilledOrder completed
order.cancelledOrder cancelled
order.shippedFulfillment shipped with tracking
shipment.deliveredFulfillment delivered
return.requestedReturn created
return.approvedReturn approved
return.rejectedReturn rejected
return.refundedReturn refunded
return.completedReturn completed

Components

OrderHistory

Paginated list of a customer’s orders. Requires authentication. Clicking a row triggers the onSelectOrder callback so you can navigate to the order detail view.
<OrderHistory />
PropTypeDefaultDescription
onSelectOrder(id: string) => voidCallback when a row is clicked
pageSizenumber10Number of orders per page

OrderDetail

Full order view showing items, totals, fulfillment status, shipping and billing addresses, and a cancel button when the order is eligible for cancellation.
<OrderDetail orderId="ord_abc123" onBack={() => setView("history")} />
PropTypeDescription
orderIdstringThe order ID to display
onBack() => voidBack navigation callback

OrderReturns

Return requests section for a specific order. Displays existing return requests and exposes a form to submit a new one. Returns are available for orders in completed or processing status.
<OrderReturns
  orderId="ord_abc123"
  items={orderItems}
  orderStatus="completed"
/>
PropTypeDescription
orderIdstringThe order ID
itemsOrderItem[]Order items for return item selection
orderStatusstringCurrent order status

OrderTracker

Public order tracking form. No authentication required. Customers enter their order number and the email address used at checkout to retrieve order status.
<OrderTracker />

Types

type OrderStatus =
  | "pending" | "processing" | "on_hold"
  | "completed" | "cancelled" | "refunded";

type PaymentStatus =
  | "unpaid" | "paid" | "partially_paid" | "refunded" | "voided";

type ReturnStatus =
  | "requested" | "approved" | "rejected"
  | "shipped_back" | "received" | "refunded" | "completed";

type ReturnType = "refund" | "exchange" | "store_credit";

type OrderFulfillmentStatus =
  | "unfulfilled" | "partially_fulfilled" | "fulfilled";

interface Order {
  id: string;
  orderNumber: string;        // e.g. "ORD-lq3k7a-x9p"
  customerId?: string;
  guestEmail?: string;
  status: OrderStatus;
  paymentStatus: PaymentStatus;
  subtotal: number;           // in cents
  taxAmount: number;
  shippingAmount: number;
  discountAmount: number;
  total: number;
  currency: string;
  notes?: string;
  metadata: Record<string, unknown>;
  createdAt: Date;
  updatedAt: Date;
}

interface OrderItem {
  id: string;
  orderId: string;
  productId: string;
  variantId?: string;
  name: string;       // snapshotted at order creation
  sku?: string;
  price: number;      // snapshotted at order creation, in cents
  quantity: number;
  subtotal: number;
  metadata: Record<string, unknown>;
}

interface Fulfillment {
  id: string;
  orderId: string;
  status: OrderFulfillmentStatus;
  trackingNumber?: string;
  trackingUrl?: string;       // auto-generated for UPS, USPS, FedEx, DHL
  carrier?: string;
  notes?: string;
  shippedAt?: Date;
  deliveredAt?: Date;
  createdAt: Date;
  updatedAt: Date;
}

interface ReturnRequest {
  id: string;
  orderId: string;
  status: ReturnStatus;
  type: ReturnType;
  reason: string;
  customerNotes?: string;
  adminNotes?: string;
  refundAmount?: number;
  trackingNumber?: string;
  trackingUrl?: string;
  carrier?: string;
  createdAt: Date;
  updatedAt: Date;
}
Item name and price are snapshotted at order creation time. Subsequent changes to the product catalog do not affect existing order records.