Add a Custom Currency to Easy Digital Downloads
Adds a currency that Easy Digital Downloads does not list by default, with its own symbol, so you can choose it in Downloads > Settings > General.
Opens WPIDE on
Code
$wpide_edd_currency = array(
'code' => 'GHS', // ISO 4217 code.
'name' => 'Ghanaian Cedi',
'symbol' => 'GH₵',
);
add_filter( 'edd_currencies', function ( $currencies ) use ( $wpide_edd_currency ) {
$currencies[ $wpide_edd_currency['code'] ] = sprintf( '%1$s (%2$s)', $wpide_edd_currency['name'], $wpide_edd_currency['symbol'] );
return $currencies;
} );
add_filter( 'edd_currency_symbol', function ( $symbol, $code ) use ( $wpide_edd_currency ) {
return $code === $wpide_edd_currency['code'] ? $wpide_edd_currency['symbol'] : $symbol;
}, 10, 2 );
Notes
Use the official three-letter ISO code, and check that your payment gateway supports the currency.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.