Wishlist Module
In this section of the documentation, you will find resources to learn more about the Wishlist Module and how to use it in your application. Mercur has wishlist features available out-of-the-box through the Wishlist 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 Wishlist Module. Learn more about why modules are isolated in this documentation.Wishlist Features
- Product Wishlists: Allow customers to save products they’re interested in for future purchase consideration.
- Customer-Specific Wishlists: Each customer has their own isolated wishlist with saved items.
- Price Calculation: Automatically calculate current prices for wishlist products including promotional pricing.
- Product Availability: Track product availability and variant information for wishlisted items.
- Easy Management: Add and remove products from wishlist with simple workflows.
How to Use the Wishlist 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 wishlist operations in the@mercurjs/b2c-core package.
For example, the createWishlistEntryWorkflow:
src/workflows/wishlist/create-wishlist.ts
API Route
src/api/store/wishlist/route.ts
Concepts
In this document, you’ll learn about the main concepts related to wishlists in Mercur.Wishlist
A wishlist is a collection of products that a customer has saved for future consideration. It is represented by the Wishlist data model. A wishlist entry holds information about:- A unique ID
- The type of reference (currently only
product) - Created and updated timestamps
Customer-Product Relationship
Wishlists create a many-to-many relationship between customers and products:- Customer → Wishlist (one-to-one): Each customer has one wishlist container
- Wishlist → Product (one-to-many): The wishlist can contain many saved products
- Customer to their Wishlist
- Wishlist to multiple Products
Reference Types
Thereference field indicates what type of entity is being saved to the wishlist:
product (Currently Supported)
Saves a product reference to the wishlist. This is the standard wishlist functionality for e-commerce.Future Extensibility
The reference system is designed to be extensible. Future implementations could add:seller: Save favorite sellerscollection: Save favorite collectionssearch: Save search queries
product references are implemented.
Price Calculation
When retrieving wishlist items, Mercur automatically calculates current prices through thecalculateWishlistProductsPrice utility:
What it does:
- Fetches current prices for wishlist products
- Applies any active promotions or price lists
- Includes variant pricing information
- Respects customer group pricing if applicable
- Returns formatted product objects with calculated prices
Delete Cascade
Both wishlist module links havedeleteCascade enabled:
- When a customer is deleted, their wishlist is automatically deleted
- When a wishlist is deleted, all wishlist entries are automatically removed
Authentication Integration
Wishlists are customer-specific and require authentication:- Routes use
authenticate("customer")middleware - Wishlist entries are filtered by
customer_idfromreq.auth_context.actor_id - Customers can only see and manage their own wishlist items