Marketplace Module
In this section of the documentation, you will find resources to learn more about the Marketplace Module and how to use it in your application. Mercur has order set management features available out-of-the-box through the Marketplace Module. A module is a standalone package that provides features for a single domain. Each of Mercur’s marketplace features are placed in custom modules, such as this Marketplace Module. Learn more about why modules are isolated in this documentation.Marketplace Features
- Order Set Management: Group multiple vendor orders from a single customer checkout into an order set for unified tracking.
- Multi-Vendor Order Tracking: Associate multiple orders with a single cart and payment collection when customers purchase from multiple sellers.
- Order Aggregation: Calculate aggregated totals, status, and fulfillment information across all orders in a set.
- Unified Customer View: Provide customers with a single view of their multi-vendor orders while maintaining individual order records per seller.
How to Use the Marketplace Module
In your Medusa application, you build flows around Commerce Modules. A flow is built as a Workflow, which is a special function composed of a series of steps that guarantees data consistency and reliable roll-back mechanism. You can build custom workflows and steps. Mercur provides pre-built workflows for marketplace operations in the@mercurjs/b2c-core package.
For example, the getFormattedOrderSetListWorkflow:
src/workflows/order-set/get-formatted-order-set-list.ts
API Route
src/api/admin/order-sets/route.ts
Subscriber
src/subscribers/notification-admin-new-order-set.ts
Concepts
In this document, you’ll learn about the main concepts related to order sets in Mercur.Order Set
An order set is a grouping of multiple orders created from a single cart in a multi-vendor marketplace. It is represented by the OrderSet data model. When a customer checks out a cart containing products from multiple sellers, Mercur:- Creates one
OrderSetto represent the entire purchase - Creates individual
Orderrecords for each seller - Links all orders to the order set
- The cart that was used for the purchase
- The customer who made the purchase
- The sales channel where the purchase was made
- The payment collection containing payment details
- All individual seller orders created from the cart
Why Order Sets?
In a traditional single-vendor e-commerce platform, one cart results in one order. In a multi-vendor marketplace, this creates complexity: Without Order Sets:- Customer sees multiple separate orders (confusing UX)
- No unified tracking for a single purchase session
- Difficult to aggregate totals and status
- Payment tracking becomes fragmented
- Customer sees one unified order set (better UX)
- Single reference point for the entire purchase
- Easy aggregation of totals across vendors
- Simplified payment and fulfillment tracking
Order Set Properties
Display ID
Thedisplay_id is an auto-incrementing number that provides a user-friendly reference for the order set (e.g., #1001, #1002). This is what customers see instead of the UUID.
Linked Entities
An order set maintains read-only links to:- Customer: The customer who placed the order
- Cart: The cart that was converted to orders
- SalesChannel: The channel where the purchase was made
- PaymentCollection: The payment information for the entire order set
Formatted Order Sets
Mercur provides aformatOrderSets utility that aggregates information from individual orders to present unified order set data:
Aggregated Properties:
- status: Overall order set status (derived from individual order statuses)
- payment_status: Overall payment status (from payment collection)
- fulfillment_status: Overall fulfillment status (across all orders)
- total: Sum of all order totals
- subtotal: Sum of all order subtotals
- tax_total: Sum of all tax amounts
- shipping_total: Sum of all shipping amounts