How to change currency symbol in WooCommerce – tutorial with code

The way the currency is displayed in WooCommerce is predefined. There is no natural way to change currency symbol – by entering it in some setup field, for example.

WooCommerce is today the dominant basis for the development of e-commerce sites under WordPress. However, WC was designed a long time ago and carries many limitations from that time, when the client's requirements and developer expectations were significantly lower than today.

Recently, in practice, I came across the need to display the Serbian dinar, which WooCommerce displays exclusively in Cyrillic (РСД), on the site I worked on to be written in Latin script (RSD). Problems with displaying dollar currencies are also common – for the US dollar, many would like it to be displayed as USD, US$, or USD$ – but WooCommerce displays it as $. Of course, there are more examples of the need to overcome this limitation.

The easiest way to change the currency symbol in WooCommerce is by inserting a short PHP code. Yes, I know that many of you who are designers and not developers are afraid of coding – but this is not difficult to do, you will see 🙂

To do this job, we need to add a little PHP code to our site.

How are we going to do this?

This can be done in two ways.

The traditional way is to use additional code to upgrade the functions.php file located in the root directory of the active WordPress theme. In order not to lose the changes made in this way the next time you update this theme, you need to first create a child theme, activate it and then make changes to it.

The first way I mentioned can be a bit complicated for beginners. For this reason, I will continue with the explanation using a different approach. I will use a plugin that allows us to add custom code directly from the WP dashboard. In any case, the code that is added is the same, so more advanced users will have no problem directly modifying their function.php file if they so wish.

We will now work in the following order:

  1. Installing the required plugin
  2. This is followed by creating the PHP code needed to change the currency symbol in WooCommerce
  3. Using the plugin, we will create an item with this code and activate it on the site.

 

Plugin installation

The plugin we want to install, and which I will use in this example, is called Code Snippets. It's free, great rated by a large number of WP developers, and can be downloaded from the WP repository from this location>>

We will install the plugin from the WP dashboard. Activate the option WP dashboard > Plugins (1) > Add New (2) and enter the name Code Snippets in the search field (3). The first plugin offered will be the one we need. Click the Install Now (4) button:

Adding the Code Snippets plugin
Click to enlarge

And then the Activate button, which will appear in that place after the first step of the installation:

Activate the Code Snippets plugin
Click to enlarge

Upon successful activation, the Code Snippets plugin will appear in the list of active WordPress plugins, and the main menu on the WP dashboard will get a new item: Snippets.

Code Snippets plugin after activation
Click to enlarge

 

Creating the PHP code we need for changing the currency symbol

Once we have installed and activated the plugin we need, it is time to prepare the code that we will use.

You can prepare the code directly in the Code Snippets plugin, and you can also first prepare it in a text editor (free Notepad ++ or something similar) and then, when prepared, copy it into the plugin.

I will now provide a basic version of the PHP code. In my example, the code will force WooCommerce to use the US$ instead of the standard $ sign to display the US dollar, to make this currency better different from the Canadian, Australian… currency of the same name:

/**
* Changing WooCommerce currency symbol from $ to US$
*/
add_filter('woocommerce_currency_symbol', 'change_currency_symbol', 10, 2);

function change_currency_symbol( $woo_currency_symbol, $woo_currency_code ) {
    switch( $woo_currency_code ) {
        case 'USD': $woo_currency_symbol = 'US$'; break;
    }
    return $woo_currency_symbol;
}

If you want to change another currency, you need to change the currency code (in this case, USD) and enter the new symbol you want for that currency (in this case, US $)

Activate the code for changing the currency symbol

Now we still have to activate the PHP code for changing the currency symbol on our website.

Prior to activating this code, the prices (this example is from the demo of the Choco Concept integrated Elementor kit) were displayed as follows:

Displays the currency before changing the currency symbol

We will now enter and activate our previously prepared PHP code:

From the WordPress dashboard, we will activate the Snippets (1) > Add new (2) option. A code entry form will open.

We will enter the name in the field above (3). This name is for internal use only, it is not displayed on the website front-end. It is used to know which code is in question if there is more than one on the list.

In the Code field (4) we will copy the complete code that we have just prepared.

Finally, we will click the Save Changes and Activate button (5).

Adding new code snippets for change currency symbol in WooCommerce
Click to enlarge

And that would be all: we have finished this job. By activating our code, we have changed the currency symbol. The price of the product from the previous image is now shown as follows:

Product after changing the currency symbol

It wasn't that complicated to do this, was it? 🙂

The way the currency code is displayed in WooCommerce is predefined. There is no natural way to change currency symbol – by entering it in a setting field, for example. The easiest way to change the currency symbol in WooCommerce is to insert a short PHP code.

About the author

Obren Markov, Senior WordPress Developer and Elementor Expert

Obren Markov is a WordPress developer and designer with many years of experience in this field and several dozen created websites behind him. He is an Elementor Professional and the author of Template sets, who creates sites for end-users. Also works with agencies and independent WP designers as a subcontractor on their projects.