This directory holds the code for the Personalized Products Recipe Tutorial.
You can either:
- install and use it as a Medusa application;
- or copy its source files into an existing Medusa application.
- Clone the repository and change to the
personalized-productsdirectory:
git clone https://github.com/medusajs/examples.git
cd examples/personalized-products2. Rename the .env.template file to .env.
3. If necessary, change the PostgreSQL username, password, and host in the DATABASE_URL environment variable.
4. Install dependencies:
yarn # or npm install5. Setup and seed the database:
npx medusa db:setup
yarn seed # or npm run seed6. Start the Medusa application:
yarn dev # or npm run devCheck the Features section for more details on how to create and use personalized products.
If you have an existing Medusa application, copy the following directories and files into your project:
src/adminsrc/apisrc/workflows
This implementation of personalized products assume a product is personalized if it has the following metadata key-value:
{
"metadata": {
"is_personalized": true
}
}You can set the metadata of any product from the Medusa Admin, as explained in the Edit Product user guide.
This example assumes the personalized product can have a custom height and width properties. Using the /store/variants/:id/price API route, you can retrieve the custom price of a personalized product.
To add a personalized product to the cart with a custom price, use the /store/carts/:id/line-items-custom.
The item added to the cart will have the personalized data (height and width) stored in its metadata property. The metadata is copied to the order's line items' metadata once the customer places the order.
If an order has personalized items, you can view their details in the order's details page on the Medusa Admin dashboard.
- Medusa Documentatin
- OpenAPI Spec file: Can be imported into tools like Postman to view and send requests to this project's API routes.