Back to Top

Custom block in order confirmation email template using PrestaShop

Updated 26 April 2022

In this blog, We are going to learn how we can add a custom block in order confirmation email templated using PrestaShop. We can achieve this by using the below explained steps.

Step 1:

We can add custom information by making changes in core files which are explained below.

Firstly, We need to make some changes (as per your requirement) in PRESTASHOP_DIR/classes/PaymentModule.php file in validateOrder() function.

For example, We have just added a custom text in the email template for info. Check below code for more information.

File Path: PRESTASHOP_DIR/classes/PaymentModule.php

Searching for an experienced
Prestashop Company ?
Find out More
$product_var_tpl = [
    'id_product' => $product['id_product'],
    'id_product_attribute' => $product['id_product_attribute'],
    'reference' => $product['reference'],
    'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''),
    'price' => Tools::getContextLocale($this->context)->formatPrice($product_price * $product['quantity'], $this->context->currency->iso_code),
    'quantity' => $product['quantity'],
    'customization' => [],
    'delivery_message' => "Your order will be delivered within 1-2 days.", // Custom Information Added

After this, We need to add the desired HTML in the below file in the place where you want to show this custom information.

File Path: PRESTASHOP_DIR/mails/en/order_conf.html

Custom HTML:

<div style="margin:0px auto; max-width:604px;">
  <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
        <td style="padding: 0 50px 0; text-align: left;" align="left">
          <div style="display:inline-block; vertical-align:top; width:100%;" align="left" width="100%">
            <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                    <td style="padding: 15px; background: #d4edda; text-align: center; color: #155724; margin-bottom: 20px; display: block; border-color: #c3e6cb; font-weight: 600;"> {delivery_message} </td>

In conclusion, when we placed an order than we are getting added custom text in the order confirmation email template. Check below image.


Step 2:

We can create a separate module to manage things separately without changing core files. In this way, we can meet the requirements by overriding the PrestaShop PaymentModule.php class validateOrder() function. Also, By using this method you can override the email template.

Ex: modules/demomodule/override/classes/PaymentModule.php

That’s all about this blog. We just added a single blog for the information you can add as much as you want.

Also, you can explore our PrestaShop Development Services and a large range of quality PrestaShop Modules.

For any doubt contact us at [email protected]

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home