Skip to content

Latest commit

 

History

History

README.md

Medusa v2 Example: First-Purchase Discount

This directory holds the code for the First-Purchase Discount Tutorial.

You can either:

Prerequisites

Installation

  1. Clone the repository and change to the first-purchase-discount directory:
git clone https://github.com/medusajs/examples.git
cd examples/first-purchase-discount

2. 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 install

5. Setup and seed the database:

npx medusa db:setup
yarn seed # or npm run seed

6. Start the Medusa application:

yarn dev # or npm run dev

Then, open the Medusa Admin at localhost:9000/app and Create a Promotion with the code FIRST_PURCHASE. It can be a 10% off promotion or any other kind.

If you want to use a different promo code, change the promo code in constants.ts.

Copy into Existing Medusa Application

If you have an existing Medusa application, copy the following directories and files into your project:

  • src/subscribers
  • src/workflows
  • src/constants.ts

Then, open the Medusa Admin at localhost:9000/app and Create a Promotion with the code FIRST_PURCHASE. It can be a 10% off promotion or any other kind.

If you want to use a different promo code, change the promo code in constants.ts.

More Resources