1

Referring to the topic on this question, ahref links sent out from the order comments in Sales > Order are not showing on Email Notifications as shown on the screenshot below.

Order Comments with ahref links enter image description here

Email received but not showing ahref links enter image description here

I've check on the Email templates using FTP app > locale > en_US > template > email > sales > order_update.html , I can't configure anything to {{var comment}}. Can we do anything to enable HTML for {{var comment}}?

 <p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">You can check the status of your order by <a href="{{store url="customer/account/"}}" style="color:#1E7EC8;">logging into your account</a>.</p>
                    <p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">{{var comment}}</p>
                    <p style="font-size:12px; line-height:16px; margin:0;">
                        If you have any questions, please feel free to contact us at
                        <a href="mailto:{{config path='trans_email/ident_support/email'}}" style="color:#1E7EC8;">{{config path='trans_email/ident_support/email'}}</a>
                        or by phone at {{config path='general/store_information/phone'}}.
                    </p>
2
  • Please check submit button method in that check how they are follow the structure
    – Keyul Shah
    Sep 22, 2014 at 3:06
  • I'm not sure what you actually meant, but isn't submit buttons belong to magento core files? We can't actually do anything about it.
    – KC Chai
    Sep 22, 2014 at 3:33

2 Answers 2

3

By default Magento does not allow html tags in the order comments.
The "problem" is not in the e-mail. It's in the controller that handles the comments.
Take a look in Mage_Adminhtml_Sales_OrderController::addCommentAction.
Somewhere in there there is this line:

$comment = trim(strip_tags($data['comment'])); 

So if you want tags in comments you need to rewrite the method I mentioned above.

if you plan to show that comment in frontend also, you might need to change the template:
app/design/frotnend/{package}/{theme}/template/sales/order/view.phtml and replace:

<?php echo $this->escapeHtml($_historyItem->getComment()) ?>

with

<?php echo $_historyItem->getComment() ?>
5
  • Which means I just remove the trim(strip_tags from the code?
    – KC Chai
    Sep 22, 2014 at 6:22
  • @DroidBeginner. Basically yes, but don't edit the core code. rewrite the methods properly. See here how you can override a controller.
    – Marius
    Sep 22, 2014 at 6:29
  • Thanks, I will accept this answer. Will open a new question if I need help for rewrites on controllers. Thanks.
    – KC Chai
    Sep 22, 2014 at 6:59
  • I do want to note that removing escapeHtml() could be dangerous. This way you could end up having unwanted HTML code or even JavaScripts injected in your website.
    – 7ochem
    Jun 1, 2015 at 11:16
  • echo $this->escapeHtml($_item->getComment(), array('b', 'br', 'strong', 'i', 'u', 'a')) is there a way to include the href property in the allowed tags list? Aug 8, 2016 at 15:06
0

In Magento 1.9.1.1 links will actually work for all order mails except the order overview itself.

The tip to modify view.phtml was however very helpful, for comments to display correctly on Invoice and Creditmemo view, you will also have to edit sales/order/comments.phtml:

Change

<dd><?php echo $this->escapeHtml($_commentItem->getComment()) ?></dd>

to

<dd><?php echo $_commentItem->getComment() ?></dd>

I am still trying to figure out, how to display Shipment comments in the frontend. According to the code, this should be possible, I see however no option in the backend to display a comment on the frontend...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.