[Prestashop help] How to create, insert a new variable for modify a Prestashop email template?

In this post, we will help you how to modify a Prestashop email template for insert new Text, new variables… style your email template and make it become a professional email.

Step 1: find a *.html, *.txt of Prestashop email template which you want modify it in

  • PRESTASHOP_ROOT/mails
  • PRESTASHOP_ROOT/themes/YOUR_THEME/mails
  • PRESTASHOP_ROOT/modules/YOUR_MODULE/mails

Read more this post: How to 39 Prestashop Email Templates works in the Prestashop?

In this post, we choose order_conf.html to modify this email template as an example.

Step 2: find a PHP file where send this *.html email template. generally, the Prestashop use Mail::Send to send any email from your Prestashop website, you can find this function in classes/Mail.php

Read more: How to 39 Prestashop Email Templates works in the Prestashop?

For an example a PHP file that send order_conf.html is classes\PaymentModule.php

Mail::Send(
(int) $order->id_lang,
‘order_conf’,
$subject,
$data,

);

You can see that: 4th argument is an array which contain all of variables assigned to order_conf.html file, in above statement $data is 4th argument

You can insert many new elements into this array before Mail::Send is executed, example:

$data[‘new_variable1’] = ‘new value 1 ‘;
$data[‘new_variable2’] = ‘new value 2’;

modify-email-template-2

Step 3: Open a *.html email template as order_conf.html file

Insert a new variable that assigned in step 2 into place where you want display it.

{new_variable1}

or

<a href=”#”><strong>{new_variable1}</strong></a>

 

Related Articles

Leave a reply

You must be logged in to post a comment.