Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save DeveloperWil/7439b126a46442d840e394e195acbc58 to your computer and use it in GitHub Desktop.

Select an option

Save DeveloperWil/7439b126a46442d840e394e195acbc58 to your computer and use it in GitHub Desktop.
WooCommerce: Add A Custom Currency Label, Description and Symbol
/**
* Add custom currency label to WooCommerce
*
* @author Wil Brown zeropointdevelopment.com
* @param $currencies
* @return mixed
*/
function zpd_add_wc_currency( $currencies ) {
$currencies['BANANA'] = __( 'Banana', 'woocommerce' );
return $currencies;
}
add_filter( 'woocommerce_currencies', 'zpd_add_wc_currency' );
/**
* Add custom currency symbol to new currency label.
*
* @author Wil Brown zeropointdevelopment.com
* @param $currency_symbol
* @param $currency
* @return string
*/
function zpd_add_wc_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'BANANA': $currency_symbol = '🍌';
break;
}
return $currency_symbol;
}
add_filter('woocommerce_currency_symbol', 'zpd_add_wc_currency_symbol', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment