Jump to content

[BUG-FIX] Emails like order confirmation displaying variables like {firstname} {lastname}


Recommended Posts

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?

 

Edited by Crezzur (see edit history)
Link to comment
Share on other sites

On 10/5/2020 at 4:49 PM, Crezzur said:

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?

 

Thanks for the Info, but...

I am using PS 1.7.6.4  and I have kind of the same problem with the email: contact_form.html. The difference is that that's the only mail that appears as {firstname} etc. with email accounts using all lower case letters. After applying the mentioned solution of commenting and pasting new code on the Mail.php under classes folder the bug keeps doing its stuff. What could the problem be?, I don't know if anybody had the same problem I am having nor if it is also considered on the next fix...

Any info would be appreciated, thanks!

Victor.

Link to comment
Share on other sites

  • 3 weeks later...
  • 4 months later...

I have the same problem and I try to replace the line.

In my 1.7.7.0 mail.php there is a bit different:

$swift->registerPlugin(new Swift_Plugins_DecoratorPlugin([self::toPunycode($toPlugin) => $templateVars]));

The problem persist and I still got the emails with the variables.

Link to comment
Share on other sites

  • 1 month later...
  • 5 weeks later...
  • 1 year later...

Hello, same problem here. Nothing changes after applying patch.

PS 1.7.6.5

Order confirmation messages are sent with {variables} both to customer and shop. Email of customer is all lower-case.

Everything worked fine until yesterday. No updates/edits were made. 🤔

Any help will be very welcome!

Link to comment
Share on other sites

On 6/27/2022 at 8:42 AM, Gatto_Rosso said:

Update:

all messages are sent with {variables}, including those sent from the Contact form

Is there a way to stop this?

Prestashop 1.7.6.7

Hello, 

same problem here, from several days ago all was going well then now all variables are not send more in email. 

no changes are maded in this days to my prestashop.

Any idea?

 

 

Link to comment
Share on other sites

Hello,

things were fixed updating to PS 1.7.8.6: now email is sent with real text again.

The bug affected any email sent: not only order confirmations to both shop and customer but also messages sent from the Contact Us module. 

Let's hope that the faulty code causing this insane thing was fixed, but I think it works just because the update replaced some file — maybe it will happen again?

It would be nice to hear something from the programmers.

Best regards

Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...