Creating a New Currency

The currencies under the Payments tab on the Settings page are a list of all currencies available for your installed payment gateways. Installing payment gateways that support other currencies should add more options to the list. However, you might want to use a currency not supported by any payment gateways. This would be a common scenario for a Bank Transfer-style gateway. In this case, it would be helpful to add a custom currency to your theme.

Adding a currency is easy. Currencies can be added in either a plugin or a child theme. You’ll want to first follow our guide on how to create a child theme, or look at WordPress’s guide to writing plugins.

Payments has a single class that deals with currencies. It is called APP_Currencies. This class allows you to register new currencies, get information about installed currencies, or format prices using the currency’s symbol.

To add a currency, you’ll want to use APP_Currencies::register_currency() on the init hook.

add_action( 'init', 'myplugin_add_currency' );
function myplugin_add_currency(){
 
    // Give your currency a name and symbol
    $args = array(
       'name' => 'My Currency',
       'symbol' => 'M'
    );
    // The first argument is the currency code. Usually a 3 letter code. ( United States Dollars  = USD )
    APP_Currencies::add_currency( 'APP', $args );
 
}

note:Please change the

>

to this character >

Adding this function will add ‘My Currency’ to the list of available currencies on the list. Selecting it will cause prices to be rendered as ‘M10’.

Warning: While you have a custom currency selected, payment gateways will probably error when you try to use them. It is recommended that you turn off all payment gateways like PayPal, Google Wallet, Stripe, etc. Bank Transfer and similar gateways should be the only type of gateway turned on when using a non-standard currency.

Like this tutorial? Subscribe and get the latest tutorials delivered straight to your inbox or feed reader.

Your rating: none
Rating: 4.6 - 5 votes

Popular Add-ons

StarStruck

A fast, lightweight, and elegant star rating system for comments, pages,…


(33)
$19

CP-Tabber

Show specific custom fields as tabs on an ad detail page.


(3)
$12

Price Comparer

Jump start your Price Comparision site with products from Amazon,…


(3)
$29