Affected Prestashop versions: Prestashop 1.7.6+ (This bug is fixed and will be added in prestashop version 1.7.7+)
Issue: Emails send to customers showing variables like {firstname} , {lastname}, ...
About the error:
I have noticed a grow in a specific error on the Prestashop Forums. The error is an issue when automated e-mails are send to your customers they see variables like {firstname} , {lastname} , ...
However this is not happening with all emails send to this specific customer. After troubleshooting this issue mainly email templates that are added by modules are affected by this issue.
for example: module Contact form (contactform) which sends an order confirmation email to your customer (using email template /yourstore/mails/order_conf.html) is affected by this bug.
Why is this error happening?
Not all your customers are having this error, and the customers that have this error, only have it with specific emails. The issue is caused by customers who are registered with a email address that is written in CAPITALS. (for example: [email protected])
How to solve this issue?
Please note: Normally we will never advice you to edit the core files of Prestashop. However since this is an accepted bug-fix which will be added in Prestashop 1.7.7 and this update will not harm or affect your Prestashop store in no way possible we will, for ONCE, edit a core file. You have to keep in mind when you upgrade your Prestashop version for example from version 1.7.6.1 to 1.7.6.8 you will have to edit this file again.
Ok now, AFTER reading all of the above, we will start with editing the file which is causing this issue.
1. Open the file:
/yourstore/classes/Mail.php
2. Search for "$swift->registerPlugin" or find this code near line 555 (line number depends on which Prestashop version you have)
3. Locate following line and quote out using // (two slashes)
$swift->registerPlugin(new \Swift_Plugins_DecoratorPlugin(array($toPlugin => $templateVars)));
4. When quoted out the above line place under this line the bug-fix
// $swift->registerPlugin(new \Swift_Plugins_DecoratorPlugin(array($toPlugin => $templateVars)));
$swift->registerPlugin(new \Swift_Plugins_DecoratorPlugin(array(self::toPunycode($toPlugin) => $templateVars)));
5. Save and test
Now we have made the changes ( we have added "self::toPunycode()" ) we can save and close Mail.php.
To test if your issue is resolved.
1. Register or alter an e-mail address and make full capitalized (example: [email protected]).
2. Make sure that in the module Contact form "Send confirmation email to your customers" is enabled
3. Make an order with the email with is capitalized (example: [email protected])
4. Check your e-mail for the order confirmation the variables {firstname}, {lastname}, ... will not be displayed anymore.
Did you also had troubles with this issue and did this topic solve it for you? Hit the like button in the right corner 😉
Topic's found where the users are affected by this issue:
- How to fix Bonjour {firstname} {lastname}
- Paiement accepté: Bonjour {firstname} {lastname}
- Mail template don't work ( HALLO {FIRSTNAME} {LASTNAME} )
- Why contact_form is showing {firstname} label?
- Prestashop V 1.7 - Contact Form - No Name Fields resulting in Email showing "Firstname Lastname" Issue
- Prestashop 1.7.6.7 - Variables not replaced in sent emails
- PS 1.7.6.4. Customer confirmation eMails without data
- Problem with mail variables but only for some members of the team
- PS 1.7 Empty template message order confirmation sent to customer
- Order Confirmation auto-email not being populated?