@webexpr-agency/medusa-plugin-wishlist
v2.2.0
Published
- [Features](#features) - [Installation](#installation) - [Usage](#usage) - [Configuration](#configuration) - [Models](#models) - [API Routes](#api-routes) - [Database Schema](#database-schema) - [Postman Collection](#postman-collection) -
Downloads
483
Readme
Table of Contents
Features
- ✅ Create and manage multiple wishlists per customer
- ✅ Add/remove products to/from wishlists
- ✅ Update product quantities in wishlists
- ✅ Convert wishlist items to cart items
- ✅ Full TypeScript support
- ✅ RESTful API endpoints
- ✅ Automatic customer association
Installation
To install the plugin, run the following command in your Medusa project:
yarn add @webexpr-agency/medusa-plugin-wishlistUsage
After installation, add the plugin to your medusa-config.js file:
const plugins = [
// ... other plugins
{
resolve: `@webexpr-agency/medusa-plugin-wishlist`,
options: {
// ℹ️ Plugin options can be added here if needed in the future
},
},
]Models
Wishlist
The main entity representing a customer's wishlist:
id: Unique identifiertitle: Name of the wishlistcustomer_id: Reference to the customer who owns the wishlistmetadata: Optional custom key-value pairsitems: Collection of wishlist itemscreated_at: Timestamp of creationupdated_at: Timestamp of last update
WishlistItem
Represents a product variant in a wishlist:
id: Unique identifierwishlist_id: Reference to the parent wishlistvariant_id: Reference to the product variantquantity: Number of items (defaults to 1)metadata: Optional custom key-value pairscreated_at: Timestamp of creationupdated_at: Timestamp of last update
API Routes
Store Routes
List Wishlists
GET /store/wishlistsQuery Parameters:
limit: (number) Maximum number of wishlists to return. Default: 50offset: (number) Number of wishlists to skip. Default: 0q: (string, optional) Search query to filter wishlists by titleorder: (string, optional) Field to sort byexpand: (string, optional) Expand related relations
Get Wishlist
GET /store/wishlists/:idQuery Parameters:
expand: (string, optional) Expand related relations
Create Wishlist
POST /store/wishlistsRequest Body:
{
"title": "My Wishlist",
"metadata": {} // optional
}Update Wishlist
POST /store/wishlists/:idRequest Body:
{
"title": "Updated Title",
"metadata": {} // optional
}Delete Wishlist
DELETE /store/wishlists/:idAdd Item to Wishlist
POST /store/wishlists/:id/itemsRequest Body:
{
"variant_id": "variant_123",
"quantity": 1 // optional, defaults to 1
}Update Wishlist Item
POST /store/wishlists/:id/items/:itemIdRequest Body:
{
"quantity": 2
}Remove Item from Wishlist
DELETE /store/wishlists/:id/items/:itemIdCreate Cart from Wishlist
POST /store/wishlists/:id/checkoutRequest Body:
{
"region_id": "region_123",
"cart_id": "cart_123" // optional, if it's defined, we will add the items to the existing cart
}Note: This will return a cart object with the items from the wishlist.
Database Schema
Wishlist Table
CREATE TABLE "wishlist" (
"id" character varying NOT NULL,
"created_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
"updated_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
"title" character varying NOT NULL,
"customer_id" character varying,
"metadata" jsonb,
CONSTRAINT "PK_wishlist_id" PRIMARY KEY ("id")
)Wishlist Item Table
CREATE TABLE "wishlist_item" (
"id" character varying NOT NULL,
"created_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
"updated_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
"wishlist_id" character varying NOT NULL,
"variant_id" character varying NOT NULL,
"quantity" integer NOT NULL DEFAULT 1,
"metadata" jsonb,
CONSTRAINT "PK_wishlist_item_id" PRIMARY KEY ("id")
)Indexes and Constraints
CREATE INDEX "IDX_wishlist_customer_id" ON "wishlist" ("customer_id")
CREATE INDEX "IDX_wishlist_item_wishlist_id" ON "wishlist_item" ("wishlist_id")
CREATE INDEX "IDX_wishlist_item_variant_id" ON "wishlist_item" ("variant_id")
ALTER TABLE "wishlist"
ADD CONSTRAINT "FK_wishlist_customer"
FOREIGN KEY ("customer_id")
REFERENCES "customer"("id")
ON DELETE CASCADE
ON UPDATE NO ACTION
ALTER TABLE "wishlist_item"
ADD CONSTRAINT "FK_wishlist_item_wishlist"
FOREIGN KEY ("wishlist_id")
REFERENCES "wishlist"("id")
ON DELETE CASCADE
ON UPDATE NO ACTION
ALTER TABLE "wishlist_item"
ADD CONSTRAINT "FK_wishlist_item_product_variant"
FOREIGN KEY ("variant_id")
REFERENCES "product_variant"("id")
ON DELETE CASCADE
ON UPDATE NO ACTIONDownload Postman Collection
