Upon updating an order's status and electing to send a notification to the customer, the email that is sent is broken html. When I view the source of the email attachment it looks like this:
<p>Your order number <a href="<a href="https://www.example.com/user/73/orders/15">15</a>">https://www.example.com/user/73/orders/15">15</a></a> at MySite has been updated.</p>
Notice the escaped HTML tags that surround the real HTML.
I have found code that likely has a part in the output:
uc_order/uc_order.module:787:
$messages['order_update_email'] = t("[uc_order:first-name] [uc_order:last-name],\n\nYour order number [uc_order:link] at [store:name] has been updated.\n\nOrder status: [uc_order:order-status]\n\nOrder comment:\n[uc_order:last-comment]\n\nBrowse to the following page to login to your account and view your order details:\n[site:login-link]\n\n\nThanks again,\n\n[store:name]\n[site:slogan]");
The text that results from that must be going through a convert-to-html call somewhere(?), but I don't know where to find that to provide more info. It seems to convert the /n's to <p>'s fine but messes up the href's. Looks like it's trying to convert things like [uc_order:link] that are likely already html.
Comments
Comment #1
MakeOnlineShop CreditAttribution: MakeOnlineShop commentedThis is why I had to send only non-html messages.
Comment #2
Brian1234 CreditAttribution: Brian1234 commentedWhere did you find that setting?
Comment #3
Brian1234 CreditAttribution: Brian1234 commentedI ended up hacking UC core, changing the message to this:
I changed two things:
- The first token with an href, [uc_order:link], is now the plain-text [uc_order:order-number]
I wanted this to be plain-text anyways because unless the user is already logged into the site they land on the site's Access Denied page.
- Hardcoded the login link, later processing makes it an href
It would be nice if this customer-facing email could have a template like the customer and admin email's that are sent when an order is made.
Comment #4
Brian1234 CreditAttribution: Brian1234 commentedIt turns out the rule has a textarea for this message, see this thread for more info:
http://www.ubercart.org/forum/support/32926/status_update_email_broken_html
Comment #5
longwaveComment #7
Graham Leach CreditAttribution: Graham Leach commentedUbercart: Order Update Emails Are Unformatted
Status: Resolved
Category: Misconfiguration
Explanation:
When the status of an order changes, an Ubercart Order Status Update email is issued to the affected customer. Unfortunately, those emails leave a lot to be desired. They look like a run on sentence with no formatting.
Analysis:
Code that generates the message in question seems to appear in:
uc_order.module
at:
sites/all/modules/ubercart/uc_order
as:
Observations:
• This appears to be a default value.
• This value can (hopefully) be over-ridden somewhere in the Administrative GUI.
• The "\n" characters in the above are not being converted to HTML by the outgoing email system.
• Emails are consequently being displayed as a run-on sentence in web-based email systems like GMAIL.
Resolution:
In the Administrative GUI, Ubercart Order Status Update functionality resides in the Rules area, instead of residing perhaps more intuitively somewhere in the Stores (Ubercart) area that deals with Orders, which are located at:
Store >> Orders
or
Store >> Configuration >> Orders
Instead, Ubercart Order Status Update functionality resides at:
Configuration >> Workflow >> Rules
or
admin/config/workflow/rules/reaction/manage/uc_order_update_email_customer
The Ubercart Order Status Update message seems to appear in the MESSAGE area of:
admin/config/workflow/rules/reaction/manage/uc_order_update_email_customer/edit/4
This is where you place the Ubercart Order Status Update message for your primary language.
Broken Example:
The reason why this message was not working for us is that it is not being entirely converted to HTML. The [site:login-link] token (macro) was being expanded to a URL, but the rest of the text was not.
Message Format
There is a MESSAGE FORMAT drop down at the very bottom of:
admin/config/workflow/rules/reaction/manage/uc_order_update_email_customer/edit/4
Format choices are:
• Shortcodes
• Dynamic Shortcodes
• Plaintext
• PHP code
The default setting appears to be Shortcodes. Changing the format to Plaintext solved the run-on sentence issue, but then embedded HTML entities like [site:login-link] stopped working properly (the HTML involved with defining the login link URL was then being exposed as plain text).
To get the behavior we wanted, we returned the setting to Shortcodes and then re-formatted the outgoing message in HTML.
Working Example:
Source(s):
https://www.drupal.org/project/mail_edit
https://www.drupal.org/project/ubercart/issues/1941450
https://web.archive.org/web/20140106174223/http://www.ubercart.org/forum...
https://drupal.stackexchange.com/questions/267916/encode-a-line-break-in...