Question

How to add the customer email in "change email address template" in magento 2.3

Config : Stores -> Configuration -> Customer Configuration -> Account Information Options -> Change Email Template (Default Config)

Email Template :

{{template config_path="design/email/header_template"}}

<p class="greeting">{{trans "Hello,"}}</p>
<br>

<p>
    {{trans "We have received a request to change the following information associated with your account at %store_name: email." store_name=$store.frontend_name}}
    {{trans 'If you have not authorized this action, please contact us immediately at <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.
</p>
<br>

<p>{{trans "Thanks,<br>%store_name" store_name=$store.frontend_name |raw}}</p>

{{template config_path="design/email/footer_template"}}

Output now :

Hello,

We have received a request to change the following information associated with your account at My Store: email. If you have not authorized this action, please contact us immediately at example@test.com.

Thanks,
Main Web Store

Expected Result :

Hello,

We have received a request to change the following information associated with your account at My Store: email **"Customer Email"**. If you have not authorized this action, please contact us immediately at example@test.com.

Thanks,
Main Web Store
Was it helpful?

Solution

You can use the existing current customer template variable same as the store you can find the function getFullCustomerObject in the file: vendor/magento/module-customer/Model/EmailNotification.php in this method data are already passing you can modify it as per your preference.

You can refer the emailChanged function in the same file where it call the sendEmailTemplate function and it has the $templateParams params in the 4th Arguments.

So in the template, you can use the variable $customer

{{trans 'If you have not authorized this action, please contact us immediately at <a href="mailto:%store_email">%customer_email</a>' customer_email=$customer.email |raw}}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top