You can add a custom currency using the two currency filters ‘mt_currency_symbols’ and ‘mt_currency_codes’.
But, as a warning, adding these currencies only adds them for display and selection; if the payment gateway doesn’t support it, that’s still going to be an issue. Obviously, if you’re only using offline payment, that’s not a problem.
Hi Joe,
Could you give an example code on how to add filters ‘mt_currency_symbols’ and ‘mt_currency_codes’?
Best Regards,
Budi H.
Those filters are now obsolete; you’d want to use just the single filter ‘mt_currencies’. E.g.
add_filter( 'mt_currencies', 'my_currencies', 10, 1 );
function my_currencies( $currencies ) {
$currencies['CUR'] = array(
'symbol' => 'symbol',
'description' => 'Name of currency'
);
}
‘CUR’ represents the key you want to use for your currency (usually the standard abbreviation, like USD for US dollars).
I inserted those lines in theme’s functions.php. And it gave error code like this:
Warning: ksort() expects parameter 1 to be array, null given in E:\HostingSpaces\budi.hoo\ticket.recoremedia.com\wwwroot\wp-content\plugins\my-tickets\mt-payment-settings.php on line 331
screenshot:
https://dl.dropboxusercontent.com/u/7046973/Temporary/MyTickets.png
And the Currency Dropdown list is now empty as seen on screenshot.
Doh. I gave you bad code; it didn’t return the array. That should have been:
add_filter( 'mt_currencies', 'my_currencies', 10, 1 );
function my_currencies( $currencies ) {
$currencies['CUR'] = array(
'symbol' => 'symbol',
'description' => 'Name of currency'
);
return $currencies;
}
It works now, thanks Joe.