Line breaks when showing customer notes in email
Posted: Mon Aug 24, 2015 10:43 am
When a customer enters an order note, it may have line breaks ("\r\n" or "\n", depending on browser and version). When an email template is processed that includes a comment, I would like to convert these line breaks to HTML <br /> tags. I tried this:
The replacement isn't done, however. After searching the web, I tried with multiple (up to 4) "\" before the r and n, but that doesn't work either. Replacing one letter with another does work:
Does anyone know how to get .replace to replace the line breaks?
I could also "pre-process" the note(s), replacing the line breaks with <br />, then add a list of the pre-processed note(s) to the email template as a parameter and show it (them) instead of the original order note(s), but that seems like a messy workaround.
I'm still on R5 if that makes a difference.
Code: Select all
$orderNote.replace("\r\n", "<br />")
Code: Select all
$orderNote.replace("e", "z")
I could also "pre-process" the note(s), replacing the line breaks with <br />, then add a list of the pre-processed note(s) to the email template as a parameter and show it (them) instead of the original order note(s), but that seems like a messy workaround.
I'm still on R5 if that makes a difference.