Halloween Sale 15% off Ends in See the plans
PHP

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.

Don’t have WPIDE yet? Install it on your site

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

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.