How to Change Currency Symbol In WooCommerce

Change Currency Symbol In WooCommerce

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:

  1. 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.
  2. 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.
  3. 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;
    
    }
    
    
    
  4. 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.
  5. 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. 

Similar Articles

  1. How to Redirect a WordPress Page Without Plugins?