Removing Currency Symbols across Your Entire Magento Site
Currency symbols are integral to e-commerce sites like Magento, but sometimes you may want to replace them with font icons for aesthetic or functional reasons. This guide will walk you through the process of completely removing currency symbols from your entire Magento frontend.
Understanding the Default Behavior
By default, Magento includes currency symbols in various places across the site, such as product prices, order totals, and min/max prices. These are controlled by the base currency symbol configured in the admin panel under Stores > Currency.
Replacing with Font Icons
Since you’re using font icons instead of currency symbols, let’s first ensure they are properly set up:
- Upload your font icon files to a directory like
pub/static/fonts. - Include them in your theme’s CSS file (usually located at
app/design/frontend/{vendor}/{theme}/web/css/style.css). For example:
@font-face {
font-family: 'CustomCurrency';
src: url('fonts/currency-icon.eot');
/* ... other formats ... */
}
- Use the font icon in your template files (
.phtml), for instance, invendor/magento/module-catalog/view/frontend/templates/product/price.phtml:
<?= $block->getProductPriceHtml($_product) ?>
Removing Default Symbols
Now let’s remove the default currency symbols from various places:
1. Product Prices
In vendor/magento/module-catalog/view/frontend/templates/product/price.phtml, find this line:
<?= $block->getProductPriceHtml($_product) ?>
Replace it with:
<?= $_product->getFormattedFinalPrice() ?>
2. Order Totals
In vendor/magento/module-sales/view/frontend/templates/order/totals.phtml, find the foreach loop iterating over totals. Replace the currency symbol in each line:
Before (with default symbol):
<?= $total['label'] ?>: <?= $total['value'] ?>
After:
<?= $total['label'] ?>: <?= $_product->getFormattedPrice($total['value']) ?>
3. Min/Max Prices
In vendor/magento/module-catalog/view/frontend/templates/product/price/regular.phtml, replace the currency symbol in both $_product->getMinimalPrice() and $_product->getRegularPrice().
Customizing the Admin Currency Symbol
Although you’re removing the symbols from the frontend, Magento still needs to know which symbol to use for admin purposes. To configure this:
- Log into your Magento backend.
- Navigate to Stores > Configuration > General > Currency Setup.
- Change the Currency Options section’s Default Display Currency Symbol field to an empty string (or remove any currency symbol you no longer need).
- Save your changes.
Conclusion
Removing currency symbols from a Magento site requires careful modification of multiple template files and configurations. Following this guide ensures a consistent removal across all relevant sections, replacing the default symbols with your font icons.
Remember, always backup your code before making significant changes to prevent any data loss or functionality issues. If you encounter difficulties, don’t hesitate to reach out to our expert Magento developers at Laravel Company.