Hemann55 / medusa-plugin-mailjet

Mailjet Plugin for Medusa to send transactional emails.
7 stars 4 forks source link

How to use template language? #2

Closed iamfarazansar closed 11 months ago

iamfarazansar commented 1 year ago

Please provide some examples of using a template language so that we can incorporate various data, such as customer first name, last name, and order total, into an email template.

Hemann55 commented 1 year ago

Mailjet lets us create email templates like welcome emails, order confirmed, etc.

To do so, login to your mailjet account > Templates > Email Templates > Create a new template.

You can use mjml or plain html for coding the actual email. I prefer mjml as it is very difficult to do it in plain html.

To insert a variable like customer's name, click on the insert variable button on top left. For example, if you are sending a welcome email to a newly registered customer, you can use the first_name which is passed in the data object for the customer.created event in this plugin.

The template code will look like this - Dear {{var:first_name:"Customer"}},

"Customer" is fallback if the first_name is not passed due to some reason

Save and Publish the template once you are done. Mailjet will give you a 7 digit template number.

You can use this template number in this plugin's options as follows - { resolve: medusa-plugin-mailjet, options: { customer_created_template: 3452456, } }