Email Order Confirmation does not display keyboard symbols correctly.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
My site (NOP v3.5) uses a lot of Textbox type attributes, which allow shoppers to enter text, which will be engraved or monogrammed.  The order confirmation email notice displays some symbols as HTML code, rather than displaying the symbol.  For instance an ampersand "&" displays as & and an apostrophe displays as '

Is there a way to force the email notice to display the characters as text, rather than html code?

Thank you in advance for your assistance.

JohnJ
7 years ago
Hi John,

Do you mean product or checkout attributes?
7 years ago
Thank you for the reply.

Actually they are product attributes.  They are displayed in the order confirmation email as Attribute Label / Product Attribute.

JohnJ
7 years ago
So it appears it does not matter about the type of attribute, i.e. textbox, droplist, etc.  If either the attribute name, or attribute text prompt, or attribute value, contain characters such as an apostrophe, an ampersand, or semicolon, etc, they appear in the email order confirmation as html code.

Is there somewhere I can update the code to use or not use HTMLEncode?

JohnJ
7 years ago
I've just tested it on the clean installation (version 3.80) and it works just fine. I cannot reproduce it
7 years ago
this morning I created a new product attribute.  I named it "Select Possessive".  I then added the attribute to a product as follows: I set the text prompt to "You're Too Possessive", a control type of Drop-down List, and added attribute values of John's, Joe's, Ours.  Next I placed an order for the item, selecting a value of Joe's.  The confirmation email displayed:

You're Too Possessive: Joe's

It's that simple to reproduce.  On my site I use control types of textbox, which allow customers to enter text which often includes possessive and join punctuations of ' and &.  I'd like to for these to display properly in the confirmation email.

If you can point me to the control that formats the email message, I may be able to figure it our myself.

Thank you again for your assistance and insight.

JohnJ
7 years ago
John,

It still works fine out of the box =))

I presume you've made some breaking changes. Formatted messages are stored in database (OrderItem.AttributeDescription). They are formatted before an order is saved. Once an order is saved, then this property "AttributeDescription" is used in emails. See Nop.Services\Catalog\ProductAttributeFormatter.cs file to find more information about it.
7 years ago
a.m.,

Thank you for verifying this and supplying the information.  You are correct, the attributes are being stored in the AttributeDescription table as htmlEncoded text, so the database stores the ' string rather than an apostrophe.

This seems to work well, everywhere except in the email notice, where it displays the literal html code, rather than the html generated symbol.  This is also if a symbol is used in the TextPrompt for the ProductAttribute.

Is there a way to verify whether this behavior was fixed between v3.5 and v3.8?

What controller formats the actual email message?  Perhaps I can work from there?

JohnJ
7 years ago
It works fine in the emails as well (verified several times). And it also works fine in version 3.50 out of the box (verified)

Regarding the controller which formats it. Please see my previous reply. You can also debug it in "ProductListToHtmlTable" method of \Nop.Services\Messages\MessageTokenProvider.cs
7 years ago
a.m.

I think I have it working now.  Hopefully, my change will not invite SQL Injection.

I added an IF condition for AttributeControlType.TextBox to the ProductAttributeFormatter file, by copying the IF condition from the multiLineTextBox controlType.  I then changed the bool value for convertPlainTextToHtml to false.

The modification has resolved the email formatting issue.  

Since the attributeDescripton field does not get written until the order is complete, I'm hoping the change will not negatively affect my database.

Thank you again for your assistance.

johnj
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.