Magento 1.9 – Order Comments Ignoring Ahref Links in Email Notification

emailemail-templatesmagento-1.9

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>

Best Answer

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() ?>
Related Topic