Built by

luluhoc

Category

Other

Version

1.1.13

Last updated

Mar 5, 2024, 18:16:37 PM2 months ago

Medusa Abandoned Cart Plugin

This plugin adds abandoned cart functionality to Medusa. It allows you to send emails to customers who have abandoned their carts. The plugin uses SendGrid to send the emails. The plugin is written in Typescript.
I strongly recommend using this plugin in combination with the Medusa Plugin SendGrid Typescript to get type safety and autocompletion for the SendGrid API. You can also use the Medusa Plugin SendGrid

Image

Features

  • Send emails to customers who have abandoned their carts.
  • Get a list of abandoned carts in Admin.

Prerequisites


How to Install

1. Run the following command in the directory of the Medusa backend:
yarn add medusa-plugin-abandoned-cart
npm install medusa-plugin-abandoned-cart
2. Set the following environment variable in
Copy to clipboard
.env
:
SENDGRID_API_KEY=<API_KEY>
SENDGRID_FROM=<SEND_FROM_EMAIL>
# IDs for different email templates
SENDGRID_ABANDONED_CART_TEMPLATE=<ORDER_PLACED_TEMPLATE_ID> # example
3. In
Copy to clipboard
medusa-config.js
add the following at the end of the
Copy to clipboard
plugins
array:
const plugins = [
// ...,
{
resolve: `medusa-plugin-abandoned-cart`,
/** @type {import('medusa-plugin-abandoned-cart').PluginOptions} */
options: {
from: process.env.SENDGRID_FROM,
subject: "You have something in your cart", // optional
templateId: process.env.SENDGRID_ABANDONED_CART_TEMPLATE,
enableUI: true,
localization: {
"de-DE": {
subject: "Sie haben etwas in Ihrem Warenkorb gelassen",
templateId: process.env.SENDGRID_ABANDONED_CART_DE_TEMPLATE,
},
},
},
},
]
Remember to run migrations after adding the plugin to the `medusa-config.js` file
4. The Sendgrid Template receives the following:
interface TransformedCart {
id: string;
email: string;
items: LineItem[];
cart_context: Record<string, unknown>;
first_name: string;
last_name: string;
totalPrice: number;
created_at: Date;
currency: string;
region: string;
country_code: string;
region_name: string;
abandoned_cart_notification_date?: string | null
abandoned_cart_notification_sent?: boolean | null
abandoned_cart_notification_count?: number | null
}

Build your own plugins

Develop your own plugins with our API to speed up your processes.

Make your plugin available via npm for it to be shared in our Plugin Library with the broader Medusa community.