Solved – Display Product Title With Special Characters in Magento 2 Mini Cart
Magento 2 mini cart displays the product title when the user adds the product to the cart. However, sometimes the product titles with special characters like ä show “& auml;” in the frontend.
For example, the product CSV file uploaded in the Magento 2 store has product names like Dress™. In the frontend mini cart, it displays as &Dress;
The expected result is to display the correct product title after converting the HTML equivalent to the characters. But the actual results differ.
To avoid that, follow the below solution to display product title with special characters in Magento 2 mini cart correctly:
Method to display product title with special characters in Magento 2 mini cart:
Find the below code in vendor\magento\module-checkout\view\frontend\web\template\minicart\item\default.html file:
1 2 3 4 5 6 7 8 |
<strong class="product-item-name"> <!-- ko if: product_has_url --> <a data-bind="attr: {href: product_url}, text: product_name"></a> <!-- /ko --> <!-- ko ifnot: product_has_url --> <!-- ko text: product_name --><!-- /ko --> <!-- /ko --> </strong> |
Replace the above code with the below code at app\design\frontend\[Theme]\[Name]\Magento_Checkout\web\template\minicart\item\default.html:
1 2 3 4 5 6 7 8 |
<strong class="product-item-name"> <!-- ko if: product_has_url --> <a data-bind="attr: {href: product_url}, html: product_name"></a> <!-- /ko --> <!-- ko ifnot: product_has_url --> <!-- ko html: product_name --><!-- /ko --> <!-- /ko --> </strong> |
That’s it.
Now you can see how the product title is displayed correctly:
Note, You can also show additional data in Magento 2 mini cart to show shipping charge, discount or tax information etc. Use the Comments section below if you have any doubts about the implementation. I’d be there for you 😊
Do share the solution with fellow developers via social media.
Thank you.
Facing issues with your Magento store or want to add new features? Our Magento Development Services are here to help!
Sanjay Jethva
Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe.
His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
Prev
How to Add Custom Entries To Admin System Configuration in Magento 2
How To Remove SKU from Product Page in Magento 2
Next