How to render HTML entities in the wishlist sidebar
-
07-02-2021 - |
Question
I have added the © symbol to product names in Magento 2. These all appear fine on the category and product pages, however when I add an item to my wishlist the product name appears with the text & copy; rather than the actual © symbol in the wishlist sidebar widget. The same applies to the recently ordered sidebar widget. See below screenshot demonstrating this:
Does anyone know how we can convert these HTML entities to the correct symbol in the sidebar widgets?
Solution
Try this by changing the data-bind text to html in all the files wherever knockout is used. See below example.
Wishlist Sidebar
Copy the file vendor\magento\module-wishlist\view\frontend\templates\sidebar.phtml to your custom theme.
From,
<strong class="product-item-name">
<a data-bind="attr: { href: product_url }" class="product-item-link">
<span data-bind="text: product_name"></span>
</a>
</strong>
To,
<strong class="product-item-name">
<a data-bind="attr: { href: product_url }" class="product-item-link">
<span data-bind="html: product_name"></span>
</a>
</strong>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange