Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Nav-Appaiya/d769d82d7256fc67bb9ec9e1c9e1a6a3 to your computer and use it in GitHub Desktop.
Save Nav-Appaiya/d769d82d7256fc67bb9ec9e1c9e1a6a3 to your computer and use it in GitHub Desktop.
Change or Remove WooCommerce currency symbol + currency symbols for other plugins
/**
* These snippets can alter or remove currency symbols from several eCommerce plugins
* They are not made to be used together! I didn't feel like creating 1MM gists :)
* Tutorial: http://www.sellwithwp.com/pricing-remove-currency-symbol/
**/
/**
* WooCommerce
**/
// Remove all currency symbols
function sww_remove_wc_currency_symbols( $currency_symbol, $currency ) {
$currency_symbol = '';
return $currency_symbol;
}
add_filter('woocommerce_currency_symbol', 'sww_remove_wc_currency_symbols', 10, 2);
// Change the US currency symbol
function sww_change_wc_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'USD': $currency_symbol = 'USD'; break;
// Can use this for any currency symbol
// ref https://github.com/woothemes/woocommerce/blob/master/includes/wc-core-functions.php#L314
}
return $currency_symbol;
}
add_filter('woocommerce_currency_symbol', 'sww_change_wc_currency_symbol', 10, 2);
/**
* Easy Digital Downloads
**/
// Removes currency symbol from the shop price display
function sww_remove_edd_currency_symbol( $output, $currency, $price ) {
$output = $price;
return $output;
}
// This will apply to USD, but the usd in this filter can be replaced with your currency symbol
// ref https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/master/includes/formatting.php#L123
add_filter( 'edd_usd_currency_filter_before', 'sww_remove_edd_currency_symbol', 10, 3 );
// Changes currency symbol from the shop price display
function sww_change_edd_currency_symbol( $output, $currency, $price ) {
$output = 'USD ' . $price;
return $output;
}
// This will apply to USD, but the usd in this filter can be replaced with your currency symbol
add_filter( 'edd_usd_currency_filter_before', 'sww_change_edd_currency_symbol', 10, 3 );
/**
* WP eCommerce
**/
// Removes the currency symbol from the shop
function sww_change_wpec_currency_code( $args ) {
$args['display_currency_symbol'] = false;
return $args;
}
add_filter( 'wpsc_toggle_display_currency_code', 'sww_change_wpec_currency_code' );
/**
* Jigoshop
**/
// Changes currency symbol to USD
function sww_change_jigoshop_currency( $symbol ) {
return 'USD ';
}
add_filter( 'jigoshop_currency_symbol', 'sww_change_jigoshop_currency' );
// Removes currency symbol
function sww_remove_jigoshop_currency( $symbol ) {
return '';
}
add_filter( 'jigoshop_currency_symbol', 'sww_remove_jigoshop_currency' );
/**
* Shopp
**/
// Changes currency symbol to USD
function sww_change_shopp_currency_format( $format ) {
$format['currency'] = 'USD ';
return $format;
}
add_filter( 'shopp_money_format', 'sww_change_shopp_currency_format' );
// Removes currency symbol
function sww_remove_shopp_currency_format( $format ) {
$format['currency'] = '';
return $format;
}
add_filter( 'shopp_money_format', 'sww_remove_shopp_currency_format' );
/**
* Exchange
**/
// Changes currency symbol to USD
function sww_change_exchange_currency( $symbol ) {
return 'USD ';
}
add_filter( 'it_exchange_get_currency_symbol', 'sww_change_exchange_currency' );
// Removes Exchange currency symbol
function sww_remove_exchange_currency( $symbol ) {
return '';
}
add_filter( 'it_exchange_get_currency_symbol', 'sww_remove_exchange_currency' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment