Developer Documentation

Add a new currency

Location of the required file

The currencies for WP ERP are controlled from wp-content/plugins/erp/includes/functions.php. To add a new currency, you have to add two new lines to the file mentioned above.

Add Name of the currency

The file has a function named erp_get_currencies(). Inside that function, you will see some lines like-

'NGN' => __( 'Nigerian Naira', 'erp' ),
'NOK' => __( 'Norwegian Krone', 'erp' ),
'NZD' => __( 'New Zealand Dollar', 'erp' ),
'OMR' => __( 'Omani Rial', 'erp')

To understand what these lines do. We will break it into 3 parts.

  1. ISO Currency Code
  2. Currency Name
  3. Text Domain

The text at the beginning of each line you see like NGN, NOK, NZD, OMR is currency codes. Their codes are defined by an authority named ISO.

The second part is the currency name and the third one is text domain. A text domain is used to translate texts in WordPress using a language file. It will be same for each line. For WP ERP, it will be erp.

So if you want to add Saudi Rial, then you need to add a line to the function mentioned above with your currency code and name. It will look something like this-

'NGN' => __( 'Nigerian Naira', 'erp' ),
'NOK' => __( 'Norwegian Krone', 'erp' ),
'NZD' => __( 'New Zealand Dollar', 'erp' ),
'OMR' => __( 'Omani Rial', 'erp' ),
'SAR' => __( 'Saudi Riyal', 'erp'  )

After adding the line above and saving the file, you will be able to see the new currency name in ERP settings page.

Add Currency Symbol

You will find another function named erp_get_currency_symbol( $currency = '' ), right below the currency name function to add the currency symbol.

case 'NPR' : $currency_symbol = 'Rs.'; break;
case 'ISK' : $currency_symbol = 'Kr.'; break;
case 'ILS' : $currency_symbol = '₪'; break;
case 'OMR' : $currency_symbol = 'ر.ع.'; break;

We already know the currency code. Just like the steps we followed above, we will copy the Unicode currency symbol and add a new line. So it will now look like this

case 'NPR' : $currency_symbol = 'Rs.'; break;
case 'ISK' : $currency_symbol = 'Kr.'; break;
case 'ILS' : $currency_symbol = '₪'; break;
case 'OMR' : $currency_symbol = 'ر.ع.'; break;
case 'SAR' : $currency_symbol = '﷼‎'; break;

Now save the file and close your text editor. You are done adding a new currency to the ERP plugin.

If you are a developer and familiar with Git, you can send us a pull request to our Github repo.

Was this article helpful to you?

How can we help?