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 &lt;a href=&quot;<a href="https://www.example.com/user/73/orders/15&quot;&gt;15&lt;/a&gt;">https://www.example.com/user/73/orders/15&quot;&gt;15&lt;/a&gt;</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

MakeOnlineShop’s picture

This is why I had to send only non-html messages.

Brian1234’s picture

Where did you find that setting?

Brian1234’s picture

I ended up hacking UC core, changing the message to this:

$messages['order_update_email'] = t("[uc_order:first-name] [uc_order:last-name],\n\nYour order number [uc_order:order-number] 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 orders:\nhttps://www.example.com\n\n\nThanks again,\n\n[store:name] \n[site:slogan]");

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.

Brian1234’s picture

It 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

longwave’s picture

Category: bug » support
Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Graham Leach’s picture

Issue summary: View changes


Ubercart: 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:

/**
 * Implements hook_uc_message().
 */
function uc_order_uc_message() {
  $messages['order_update_email'] = t("[order:first-name] [order:last-name],\n\nYour order number [order:link] at [store:name] has been updated.\n\nOrder status: [order:order-status]\n\nOrder comment:\n[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]");

  return $messages;
}

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:

[order:first-name] [order:last-name],

Your order number [order:link] at [store:name] has been updated.

Order status: [order:order-status]

Order comment:
[order:last-comment]

Browse to the following page to login to your account and view your order details:
[site:login-link]


Thanks again,

[store:name]
[site:slogan]

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:

<p>
[order:first-name] [order:last-name],
</p>
<p>
Your order number [order:link] at [store:name] has been updated.
</p>
<p>
Order status: [order:order-status]
</p>
<p>
Order comment:
[order:last-comment]
</p>
<p>
Browse to the following page to login to your account and view your order details:
[site:login-link]
</p>
<p>
Thanks again,
[store:name]
<br>
[site:slogan]
</br>
</p>

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...