The other day a blog reader asked me if you could change the currency symbol in WooCommerce , because in your case WooCommerce uses the same symbol ($) for the US dollar and the Argentine peso.
I gave you a momentary solution but today I want to expand it a bit, in case you have a similar need.
Index of contents
Change currency symbol in WooCommerce with codes
Let’s start with the simplest thing, which would be to change only one WooCommerce currency symbol . The code would be like this:
/ * Dollar symbol change * / add_filter ('woocommerce_currency_symbol', 'helpwp_change_dollar_symbol', 10, 2); function helpwp_change_dollar_symbol ($ currency_symbol, $ currency) { switch ($ currency) { case '$': $ currency_symbol = 'USD'; break; } return $ currency_symbol; }
This would be the specific example that the reader asked me, where we change the default symbol of the dollar ($) to USD, to distinguish it from others, such as the Argentine peso.
Now we are going to see another example, with a variation of the previous code, but in this case to change several currency symbols :
/ * Currency symbol exchange * / add_filter ('woocommerce_currency_symbol', 'helpwp_change_currency_symbol', 10, 2); function helpwp_change_currency_symbol ($ currency_symbol, $ currency) { switch ($ currency) { case '$': $ currency_symbol = 'USD'; break; case '€': $ currency_symbol = 'EURO'; break; case '£': $ currency_symbol = 'POUND'; break; case '¥': $ currency_symbol = 'YEN'; } return $ currency_symbol; }
We have added another set of changes here, in addition to the first example.
Another way to achieve the same result would be through conditional if
, like this:
/ * Currency symbol exchange * / add_filter ('woocommerce_currency_symbol', 'helpwp_change_currency_symbol', 10, 2); function helpwp_change_currency_symbol ($ currency_symbols, $ currency) { if ('USD' === $ currency) { return 'USD'; } if ('EUR' === $ currency) { return 'EURO'; } if ('GBP' === $ currency) { return 'POUND'; } return $ currency_symbols; }
In this type of code you must first indicate the currency code used by WooCommerce for the currency you want to modify ( if ('CODIGO' === $currency)
), and then return
what you want to show instead.
If you do not know the currency codes that WooCommerce uses, they are all of these .
How do I add these codes?
If you don’t know how to add these or other codes, I encourage you to review this simple guide on how to copy and paste codes in WordPress …
How and where to paste PHP, JS, CSS codes and functions that you find out there in WordPress
Change the currency symbol in WooCommerce with plugins
If you prefer to use a plugin to change the currency symbols in WooCommerce, there is one that serves to change the symbol of the active currency by default in WooCommerce . It is not as complete as with the previous codes but it could be useful if you only want to change the symbol of the current currency.
It’s called Change Currency Symbol and it’s very easy to use. When you have installed and activated it, go to the general WooCommerce settings and, in the currency options section you will see a new setting in which you indicate the symbol you want to replace the current currency of the settings with .
Save the changes and you have it.
YOU MAY ALSO BE INTERESTED IN …
Did you like this article? You can’t imagine what you’re missing on YouTube !