Post by kingadjon » Sat Apr 18, 2020 8:16 am

Opencart Version 3.0.3.2

When history is added to an order and an email is sent to the customer, the message is all on one line and hard to read.

Example:

Code: Select all

Order ID:23Date Added:17/04/2020Your order has been updated to the following status:ProcessingThe comments for your order are:TestingPlease reply to this email if you have any questions.
Is there anyway to add a return character after each line or adjust the formatting so it's easier to read?

Thanks!
Last edited by kingadjon on Mon Apr 20, 2020 5:41 am, edited 1 time in total.

Newbie

Posts

Joined
Fri Apr 10, 2020 10:53 am

Post by IP_CAM » Sat Apr 18, 2020 9:18 am

You could try, to change in the 'catalog/language/en-gb/mail/order_edit.php':
( and possibly in other mail-related language files as well )
this:

Code: Select all

$_['text_subject']      = '%s - Order Update %s';
$_['text_order_id']     = 'Order ID:';
$_['text_date_added']   = 'Date Added:';
$_['text_order_status'] = 'Your order has been updated to the following status:';
$_['text_comment']      = 'The comments for your order are:';
$_['text_link']         = 'To view your order click on the link below:';
$_['text_footer']       = 'Please reply to this email if you have any questions.';
to something like this:

Code: Select all

$_['text_subject']      = '%s - Order Update %s';
$_['text_order_id']     = '<p>Order ID:';
$_['text_date_added']   = '<p>Date Added:';
$_['text_order_status'] = '<p>Your order has been updated to the following status:';
$_['text_comment']      = '<p>The comments for your order are:</p>';
$_['text_link']         = '<p>To view your order click on the link below:</p>';
$_['text_footer']       = '<p>Please reply to this email if you have any questions.</p>';

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by kingadjon » Sat Apr 18, 2020 12:39 pm

Thank you for the quick reply!

I have been trying different variations of carriage returns, paragraphs and spacers and nothing seems to work for me.

I tried the code you provided and it still comes back all as one line.

Code: Select all

<p>Order ID:</p>24<p>Date Added:</p>17/04/2020<p>Your order has been updated to the following status:</p>Pending<p>The comments for your order are:</p>wewerwerwerwer<p>Please reply to this email if you have any questions.</p>
Thanks again for giving it a shot!

Newbie

Posts

Joined
Fri Apr 10, 2020 10:53 am

Post by IP_CAM » Sat Apr 18, 2020 1:44 pm

Well, I was not sure, if it would work this way, but it obviously fully removes all HTML Code.
Possibly, someone of the 'real' Pro's has a Solution for that. Good Luck!
Ernie

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by letxobnav » Sat Apr 18, 2020 1:53 pm

updates are send as text mail so putting html tags in there is futile.

either make sure your twig is saved correctly with carriage returns and line feeds preserved (and don't run some minimizer script on that) or put html tags in there (as stated above) but then change the mail type from text to html.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by kingadjon » Sat Apr 18, 2020 4:16 pm

@letxobnav

I'm open to the easiest fix without breaking the template. Currently it's default opencart 3.0.3.2 with all defaults.

Why does it not have carriage returns in the default template? It seems like it should and something is causing it not to work.

Surely it's not supposed to be sent as one line. I'm suspecting something is wrong with my config somewhere.

Thanks!

Newbie

Posts

Joined
Fri Apr 10, 2020 10:53 am

Post by letxobnav » Sat Apr 18, 2020 4:39 pm

well, could be the way the different twig files were saved when making the packages
V3.0.2.0 was saved differently than V3.0.3.2 as seen attached.
V3.0.3.2 only has linefeeds whereas V3.0.2.0 has carriage return + linefeeds in the twig file.

That might be the cause, I use a twig file with <CR><LF> and I have no issues with text mails.

Attachments

order_edit_twig_lf.JPG

order_edit_twig_lf.JPG (32.15 KiB) Viewed 3336 times

order_edit_twig_cr_lf.JPG

order_edit_twig_cr_lf.JPG (35.91 KiB) Viewed 3336 times


Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by kingadjon » Sun Apr 19, 2020 2:31 am

Thanks for the reply!

So if one adds carriage returns or line feed, it does indeed work, but it renders them in the final email. Same with paragraph.

Code: Select all

<p>Order ID:24</p>

<p>Date Added:17/04/2020</p>

<p>Your order has been updated to the following status:Pending</p>

<p>The comments for your order are:qwetqwtqwe</p>

<p>Please reply to this email if you have any questions.</p>
I've been combing through twig documentation on how to remove them using |striptags, |raw, etc..., but nothing is working. I suspect it might have to do with changing emails to HTML as you suggested before? I just don't know how.

Thanks!

Newbie

Posts

Joined
Fri Apr 10, 2020 10:53 am

Post by letxobnav » Sun Apr 19, 2020 8:24 am

you either send text mail with <cr><lf> and NO html tags or html mail with html tags, not both.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by kingadjon » Sun Apr 19, 2020 1:09 pm

LOL I'm really showing my weakness here, you can laugh at me. :-)

This is my TWIG file which is back to default:

Code: Select all

{{ text_order_id }} {{ order_id }}
{{ text_date_added }} {{ date_added }}

{{ text_order_status }}

{{ order_status }}

{% if link %}
{{ text_link }}

{{ link }}
{% endif %}
{% if comment %}

{{ text_comment }}

{{ comment }}
{{ text_footer }}
{% else %} 
{{ text_footer }}
{% endif %}
This is the email output:

Order ID:28Date Added:18/04/2020Your order has been updated to the following status:PendingThe comments for your order are:ertertertPlease reply to this email if you have any questions.

Would you mind telling me exactly what needs to be changed in order for there to be returns and spaces in the email?

Thanks for trying to help, I really appreciate your time.

Newbie

Posts

Joined
Fri Apr 10, 2020 10:53 am

Post by straightlight » Sun Apr 19, 2020 6:25 pm

Simply converting your TWIG file to HTML codes may simplify your request rather than playing with new lines, in this case. Simply change the mail method call from setText to setHtml and call in your TWIG file and $data array in the parameter. From there, you could reproduce the HTML presentation from, let's say, your catalog/view/theme/<your_theme>/template/mail folder and add it to your new TWIG file which can save you a lot of time.

Ensure, however, that the $data keys do match with your HTML TWIG file outputs. Then, follow this FAQ: viewtopic.php?f=134&t=215776#p718325

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by kingadjon » Mon Apr 20, 2020 4:12 am

Thanks everyone for the great support and quick replies. This is a great forum and an awesome cart!

That makes sense. But lets say I wanted to leave it as text.

Is there a way to simply make the default text mode email look correct? Just putting info on separate lines so it's easy to read, nothing more.

letxobnav seems to think the twig files lost the return characters somehow and that makes sense. I'm editing TWIG files from the admin panel. Would it make more sense to edit the actual file or re-create it? Maybe that's causing the issue?

Here is my order_edit.twig file showing invisible chars just using VIM:
{{·text_order_id·}}·{{·order_id·}}¶
{{·text_date_added·}}·{{·date_added·}}¶

{{·text_order_status·}}¶

{{·order_status·}}¶

{%·if·link·%}¶
{{·text_link·}}¶

{{·link·}}¶
{%·endif·%}¶
{%·if·comment·%}¶

{{·text_comment·}}¶

{{·comment·}}¶
{{·text_footer·}}¶
{%·else·%}•¶
{{·text_footer·}}¶
{%·endif·%}¶
~
~
~
~
At least on the surface, it appears to have retained returns. I think he was thinking these were stripped off somehow.

Thanks again!

Newbie

Posts

Joined
Fri Apr 10, 2020 10:53 am

Post by kingadjon » Mon Apr 20, 2020 5:40 am

Okay, I have a working solution, albeit far from elegant, it's a way to force return chars to the output and make the emails look clean. If there is a more direct or simple way to do this, I would love to know, but for now this seems to work. Feel free to laugh along with me on this logic. :laugh: :laugh: :laugh: ;D

Use the verbatim tag to insert a return character after each function.

Here's my current working TWIG file:

Code: Select all

{{ text_order_id }} {{ order_id }}

{% verbatim %}

{% endverbatim %}

{{ text_date_added }} {{ date_added }}

{% verbatim %}

{% endverbatim %}

{{ text_order_status }} {{ order_status }}

{% verbatim %}

{% endverbatim %}

{% if link %}

{{ text_link }} {{ link }}

{% verbatim %}

{% endverbatim %}

{% endif %}
{% if comment %}

{{ text_comment }} {{ comment }}

{% verbatim %}

{% endverbatim %}
{{ text_footer }}
{% else %} 
{{ text_footer }}
{% endif %}
Here's the email output:
Order ID:28

Date Added:18/04/2020

Your order has been updated to the following status:Pending

The comments for your order are:test

Please reply to this email if you have any questions.
Thanks and keep up the great work!

Newbie

Posts

Joined
Fri Apr 10, 2020 10:53 am

Post by letxobnav » Mon Apr 20, 2020 7:22 am

good.
I'm editing TWIG files from the admin panel.
Don't do that unless you absolutely have to as it saves the source in the database and that js editor messes with the source as well.
And if you absolutely have to better edit local and paste it in, never handly to edit information in an online js editor, unless you don't mind re-doing stuff.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by kingadjon » Mon Apr 20, 2020 8:45 am

I'm editing TWIG files from the admin panel.
Don't do that unless you absolutely have to as it saves the source in the database and that js editor messes with the source as well.
Thank you, I was curios about that actually! I am a proponent of doing things by the books but I do prefer editing files directly with VIM or a text editor and managing my own changes and backups.

Thanks again for the superb direction and insight. It's weird how sometimes the problems that can seem the easiest take the most time!

Newbie

Posts

Joined
Fri Apr 10, 2020 10:53 am

Post by paulfeakins » Mon Apr 20, 2020 6:25 pm

letxobnav wrote:
Mon Apr 20, 2020 7:22 am
I'm editing TWIG files from the admin panel.
Don't do that unless you absolutely have to
I can't think of any reason anyone would have to ...

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by straightlight » Mon Apr 20, 2020 7:13 pm

paulfeakins wrote:
Mon Apr 20, 2020 6:25 pm
letxobnav wrote:
Mon Apr 20, 2020 7:22 am
I'm editing TWIG files from the admin panel.
Don't do that unless you absolutely have to
I can't think of any reason anyone would have to ...
They simply don't.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by NSE Imports » Fri May 01, 2020 11:13 pm

Thanks for this, I used the verbatim method on both order_edit and order_alert, I did use the admin panel twig editor which seems to behave well enough for me and all is good :)

Live in the UK and need N95 masks? Come to our shop @ nseimports.co.uk


User avatar
Newbie

Posts

Joined
Fri May 01, 2020 7:32 pm
Location - London, UK

Post by joeantropy » Thu Aug 19, 2021 10:46 pm

We've come across this issue recently on an OpenCart site - it was found to be caused by some weirdness in certain versions of the Twig template engine when running on newer versions of PHP (7.3 and up) - it seems to be removing whitespace between elements when it shouldn't be (another common symptom of this is missing icons next to sidebar menu items in the admin panel).

I've attached a hotfix for this issue - tested working on OpenCart 3.0.2.0 with PHP7.4 but should work in your case on 3.0.3.2 if they use the same version of Twig. vQmod is required for this fix to work; drop it in your vqmod/xml folder as standard.

Attachments

Antropy fix for twig spacing issues


Newbie

Posts

Joined
Mon Mar 02, 2020 10:19 pm

Post by leandromello » Tue Jan 18, 2022 6:23 am

I solved this problem just adding some "<br>" and formating the order_info.twig.

But i still have a similar problem.
How to change the content of {{ comment }} to html?

The customer receive the e-mail in HTML, but the content of the field "comment" go with no formating at all.
For example:

I send:
"Hi,
Your order is closed."

The client receive in the e-mail:

"Hi Your order is closed"

All in one line.
How to solve this?

New member

Posts

Joined
Fri Oct 28, 2011 3:29 am
Who is online

Users browsing this forum: No registered users and 265 guests