Author Topic: Editting Email Templates goes wrong  (Read 72 times)

Offline featurespoon

  • Newbie
  • *
  • Posts: 23
  • Karma: +5/-1
    • View Profile
Editting Email Templates goes wrong
« on: August 03, 2020, 07:53:01 AM »
Email templates were introduced in version 1.2.16, I've belatedly discovered.  This has given me some grief. The original templates for order notification emails have not been removed.  So I naively thought, not having realised that these new templates had been introduced, if I edited these old templates I'd see the result in the generated emails. How wrong I was. Even if I inserted error_log's in the these templates, the 'error' message would come out, so I knew the template was being executed, but the HTML around error_log did not appear in the email (tearing of hair)!  Following the code for emails pointed me to the new email templates.  Serves me right, you might say, for not reading the release notes, but why keep the old templates, and load them?  The release notes also announced the new editor of these templates in the Control Panel.  Great! - or was it. I needed to change the column heading 'Model' to 'Author' - our shop sells books - simple enough in this editor, although a placeholder would have been useful.  When I did that the result was catastrophic. Here is a portion of the HTML produced:

<th class="align_left" style="color: #ffffff;">Author</th>
<th class="align_right" --n--="">       style="width: 10%; padding: 0.3em; color: #FFFFFF;"&gt;Price</th>
               <th class="align_right" --n--="">                style="width: 15%; padding: 0.3em; color: #FFFFFF;"&gt;Quantity</th>

My new Author line was OK, but the following lines had this extra text inserted after the "align_right".  I think what is happening is that because the <th...> tag was split over two lines, the editor has inserted this
--n--"">   What's more, the end ">" has got converted to  &gt;
The work-around is to delete the newline and keep the <th > tag on one line even it wraps around, and change the &gt: to >

In fact I found this has happened at a number of places in the template file.


Offline featurespoon

  • Newbie
  • *
  • Posts: 23
  • Karma: +5/-1
    • View Profile
Re: Editting Email Templates goes wrong
« Reply #1 on: August 03, 2020, 09:20:32 AM »
Unfortunately the problems with the email template editor don't stop there.   Well away from where I made a small change, this line:

<td class="align_left">Order ID: <span
         style="color: #069; font-weight: bold;">{{ order_id }}</span><br />

became:

<td class="align_left">Order ID: &lt;span
         style="color: #069; font-weight: bold;"&gt;{{ order_id }}<br />

Not only are some tags encoded in the PHP sense, but the end tag </span> is lost entirely.

Even worse, the iterative Mustache  tags  {{#products}}, {{/products}} {{#totals}}, and {{/totals}} are lost entirely and even some
singular tags for {{#comment}} and {{/invoice}}.  This means that you get out emails without any products or any totals listed for the order.  Quite useless for the customer.

So my advice is, make a copy of the template before you start editting.  You may have to go back and add the things that got lost.  That does work and I now have a good working template.


Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 4606
  • Karma: +225/-1
    • View Profile
Re: Editting Email Templates goes wrong
« Reply #2 on: August 04, 2020, 01:37:22 AM »
Hello.
If you edit in the visual editor mode it can remove some code. Please use the regular editor mode
« Last Edit: August 04, 2020, 07:36:14 PM by Basara »
“Chuck Norris is so amazing.”
― Mother Teresa

Offline featurespoon

  • Newbie
  • *
  • Posts: 23
  • Karma: +5/-1
    • View Profile
Re: Editting Email Templates goes wrong
« Reply #3 on: August 04, 2020, 06:35:28 AM »
I used the regular editor.  I did once switch to the visual editor to see what it looked like, but didn't edit in that mode.  Would that be enough to cause what I experienced?  One other thing occurred to me. I was unfortunately using an old version of PHP.  4.4 I think it was.  As this editor must rely on the PHP functions html_entity_decode and html_entities, if there were any bugs in them could that be the cause?

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 4606
  • Karma: +225/-1
    • View Profile
Re: Editting Email Templates goes wrong
« Reply #4 on: August 04, 2020, 08:11:57 AM »
Hello.
The PHP 4.4 is not secure and AbanteCart do not support it
7+ is recommended
“Chuck Norris is so amazing.”
― Mother Teresa

Offline featurespoon

  • Newbie
  • *
  • Posts: 23
  • Karma: +5/-1
    • View Profile
Re: Editting Email Templates goes wrong
« Reply #5 on: August 04, 2020, 01:00:00 PM »
I've now made sure that the PHP version is 7.4.  I went into the email template editor and changed one word and saved.  The result was OK. I then went in again and switched to the Visual Editor, did not make any changes and then switched back to the regular editor. I could then see that the </span> was missing as was the iterative Mustache tags for product and total as mentioned previously. I think the Visual editor should be disabled and certainly should be avoided by anybody editting email templates.

 

Powered by SMFPacks Social Login Mod