From 9d7ed9dbafe4d73caa7330b4cd3cb50689eccdc2 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Tue, 23 Jan 2024 10:36:34 +0200 Subject: [PATCH] docs: rearrange sections in SendGrid guide (#6165) Rearrange sections in the sendgrid plugin guide to show installation steps before templates reference. --- .../plugins/notifications/sendgrid.mdx | 218 +++++++++--------- 1 file changed, 109 insertions(+), 109 deletions(-) diff --git a/www/apps/docs/content/plugins/notifications/sendgrid.mdx b/www/apps/docs/content/plugins/notifications/sendgrid.mdx index 6b080ad140..695d19c077 100644 --- a/www/apps/docs/content/plugins/notifications/sendgrid.mdx +++ b/www/apps/docs/content/plugins/notifications/sendgrid.mdx @@ -69,13 +69,120 @@ Medusa supports localization so you can also create multiple templates for multi --- +## Install the SendGrid Plugin + +In the directory of your Medusa backend run the following command to install the SendGrid plugin: + +```bash npm2yarn +npm install medusa-plugin-sendgrid +``` + +Then, in your `.env` file add the API key you created earlier as well as the send from email: + +```bash +SENDGRID_API_KEY= +SENDGRID_FROM= +``` + +Make sure to replace the `` with the SendGrid API key and the `` with the email you’re using in SendGrid as the single sender. + +Also, you should add the ID of each template you create in `.env` as well. For example: + +```bash +SENDGRID_ORDER_PLACED_ID= +``` + +Where ` { + const sendgridService = req.scope.resolve("sendgridService") + const sendOptions = { + templateId: "d-123....", + from: "ACME ", + to: "customer@mail.com", + dynamic_template_data: { dynamic: "data" }, + } + sendgridService.sendEmail(sendOptions) +} +``` + +--- + ## Template Reference -This section covers the template types supported by the plugin and what variables you can expect in your dynamic template. You can use the variables to add Details like order total or customer name. +This section covers the template types supported by the plugin and what variables you can expect in your dynamic template. You can use the variables to add details like order total or customer name. :::note -You don’t have to create a template for every type in the reference. You can simply create templates for the type of emails you want to send using Medusa and SendGrid, +You don’t have to create a template for every type in the reference. You can simply create templates for the type of emails you want to send. ::: @@ -3916,113 +4023,6 @@ You don’t have to create a template for every type in the reference. You can s --- -## Install the SendGrid Plugin - -In the directory of your Medusa backend run the following command to install the SendGrid plugin: - -```bash npm2yarn -npm install medusa-plugin-sendgrid -``` - -Then, in your `.env` file add the API key you created earlier as well as the send from email: - -```bash -SENDGRID_API_KEY= -SENDGRID_FROM= -``` - -Make sure to replace the `` with the SendGrid API key and the `` with the email you’re using in SendGrid as the single sender. - -Also, you should add the ID of each template you create in `.env` as well. For example: - -```bash -SENDGRID_ORDER_PLACED_ID= -``` - -Where ` { - const sendgridService = req.scope.resolve("sendgridService") - const sendOptions = { - templateId: "d-123....", - from: "ACME ", - to: "customer@mail.com", - dynamic_template_data: { dynamic: "data" }, - } - sendgridService.sendEmail(sendOptions) -} -``` - ---- - ## See Also - [Notifications Overview](../../development/notification/overview.mdx)