chore: Merge master to develop (#3653)

This commit is contained in:
Oliver Windall Juhl
2023-03-31 13:09:57 +02:00
committed by GitHub
parent b2e2eddcea
commit 809ab2e0eb
120 changed files with 2240 additions and 585 deletions
+60 -21
View File
@@ -1,29 +1,68 @@
# medusa-plugin-mailchimp
# Mailchimp
Mailchimp plugin for Medusa that supports newsletter subscriptions.
Manage newsletter subscriptions in your commerce application with Mailchimp.
Learn more about how you can use this plugin in the [documentaion](https://docs.medusajs.com/add-plugins/mailchimp).
[Mailchimp Plugin Documentation](https://docs.medusajs.com/plugins/notifications/mailchimp) | [Medusa Website](https://medusajs.com/) | [Medusa Repository](https://github.com/medusajs/medusa)
## Options
## Features
```js
{
api_key: "MAILCHIMP_API_KEY",
newsletter_list_id: ["123456789"]
}
```
- Allow customers to subscribe to your newsletter.
- Provides custom services and endpoints to give developers flexibility in how to implement newsletter subscription.
## Dynamic usage
---
You can resolve the Mailchimp service, such that your server can handle newsletter subscriptions.
## Prerequisites
Example:
- [Medusa backend](https://docs.medusajs.com/development/backend/install)
- [Mailchimp account](https://mailchimp.com/signup)
```js
const mailchimpService = req.scope.resolve("mailchimpService")
mailchimpService.subscribeNewsletter(
"acme@mail.com",
// merge_fields to include in the subscription
{ FIRSTNAME: "Acme", LASTNAME: "Inc." }
)
```
---
## How to Install
1\. Run the following command in the directory of the Medusa backend:
```bash
npm install medusa-plugin-mailchimp
```
2\. Set the following environment variables in `.env`:
```bash
MAILCHIMP_API_KEY=<YOUR_API_KEY>
MAILCHIMP_NEWSLETTER_LIST_ID=<YOUR_NEWSLETTER_LIST_ID>
```
3\. In `medusa-config.js` add the following at the end of the `plugins` array:
```js
const plugins = [
// ...,
{
resolve: `medusa-plugin-mailchimp`,
options: {
api_key: process.env.MAILCHIMP_API_KEY,
newsletter_list_id:
process.env.MAILCHIMP_NEWSLETTER_LIST_ID,
},
},
]
```
---
## Test the Plugin
1\. Run the following command in the directory of the Medusa backend to run the backend:
```bash
npm run start
```
2\. Use the `/mailchimp/subscribe` endpoint or the `MailchimpService` to subscribe to the newsletter.
---
## Additional Resources
- [Mailchimp Plugin Documentation](https://docs.medusajs.com/plugins/notifications/mailchimp)