Are you looking for the easiest and quick way to change currency symbols in WooCommerce? In this quick tutorial, I am going to show you how you can quickly change the currency symbol of any WooCommerce currency.
In the previous post, I shared with you how to add currency to WooCommerce and now, I want to show you how to change currency symbols in WooCommerce’s existing currencies.
Change Currency Symbol In WooCommerce
In this post, I want to show you step-by-step how you can change the WooCommerce currency symbol using a code snippet.
Possibly we can build a change currency symbol in the WooCommerce plugin in the future that will make it easy for everyone to change currency symbols in WooCommerce without editing the theme files.
For now, lets us focus on the steps you can take to change the currency symbol in WooCommerce:
- Ensure you begin by creating a backup of your WooCommerce theme since when you add the code snippet you can easily mess up and lead to the loss of your site. Backup is always recommended when you are adding any changes to the
functions.php
file of your theme. - Create a child theme of your current activities that we will use to add the code snippet to change the WooCommerce currency symbol. If you have not created a child theme before, I would like to recommend you check out my step-by-step guide on how to create a Storefront Child theme that I shared before.
- After you have created the child theme, you can now open the
functions.php
file of the child theme and add the code snippet below :<?php /** * Custom Change Currency Symbol In WooCommerce */ add_filter('woocommerce_currency_symbol', 'njengah_change_currency_symbol_woocommerce', 10, 2); function njengah_change_currency_symbol_woocommerce( $currency_symbol, $currency ) { switch( $currency ) { case 'ABC': $currency_symbol = '$'; break; } return $currency_symbol; }
- After you add this code snippet and updated the changes you should see the specific currency symbol change to reflect the currency symbol you add to the code above. It’s important that you change the code to reflect the specific currency symbol that you want to customize.
- You can also change multiple currency symbols using one code snippet that extends this logic using the switch statement or the if statement as in the code snippet below :
Using Switch Statement
<?php /** * Custom Change Multiple Currency Symbols In WooCommerce */ add_filter('woocommerce_currency_symbol', 'njengah_change_currency_symbol_woocommerce', 10, 2); function njengah_change_currency_symbol_woocommerce( $currency_symbol, $currency ) { switch( $currency ) { case 'ABC': $currency_symbol = '$'; break; case 'DEF': $currency_symbol = '*'; break; case 'XYZ': $currency_symbol = '#'; break; case 'FGH': $currency_symbol = '@'; } return $currency_symbol; }
Using If Statement
<?php /** * Custom Change Multiple Currency Symbols In WooCommerce */ add_filter('woocommerce_currency_symbol', 'njengah_change_currency_symbol_woocommerce', 10, 2); function njengah_change_currency_symbol_woocommerce( $currency_symbols, $currency ) { if ( 'USD' === $currency ) { return 'USD'; } if ( 'EUR' === $currency ) { return 'Euro'; } if ( 'AED' === $currency ) { return 'AED'; } return $currency_symbols; }
Conclusion
In this post, we have looked at how to change currency symbols using a code snippet that you can add to your child theme’s functions.php
file or via a custom plugin.
As a quick reminder, it’s always a good precaution to avoid adding custom snippets directly to your parent theme since this will always lead to breaking your site when there are updates or if you have a syntax error in your code. If you would like help from a professional WooCommerce developer feel free to get in touch with me at the earliest opportunity.
Joe is an experienced full-stack web developer with a decade of industry experience in the LAMP & MERN stacks, WordPress, WooCommerce, and JavaScript – (diverse portfolio). He has a passion for creating elegant and user-friendly solutions and thrives in collaborative environments. In his spare time, he enjoys exploring new tech trends, tinkering with new tools, and contributing to open-source projects. You can hire me here for your next project.
Similar Articles
- How to Get Checkout URL In WooCommerce
- How to Get Product ID on the Checkout Page Or Order Page In WooCommerce
- How to Move Primary Menu Storefront WooCommerce
- How to Style WooCommerce Checkout Page
- How to Hide Storefront Mobile Cart Icon In WooCommerce
- How to Add Currency to WooCommerce [Custom Currency]
- How to Fix WooCommerce Storefront Theme Internal 500 Server Error
- How to Hide Prices From Google In WooCommerce
- How to Create Checkbox Field in WooCommerce Checkout Page
- 5+ Best WooCommerce Store Examples
- How to Change Checkout Endpoints WooCommerce
- How to Hide Price When Out of Stock In WooCommerce
- How to Clear Cart on Logout In WooCommerce
- How to Get Product Description & Display WooCommerce
- 30 Best Download Plugins for WordPress File Sharing & More
- How to Change WooCommerce Checkout Page Title
- How to Redirect a WordPress Page Without Plugins?