Add a custom currency / symbol
To add a custom currency paste this code in your theme functions.php file and swap out the currency code and symbol with your own. After doing so it will be available from WooCommerce settings.
add_filter( 'woocommerce_currencies', 'add_my_currency' );
function add_my_currency( $currencies ) {
$currencies['ABC'] = __( 'Currency name', 'woocommerce' );
return $currencies;
}
add_filter('woocommerce_currency_symbol', 'add_my_currency_symbol', 10, 2);
function add_my_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'ABC': $currency_symbol = '$'; break;
}
return $currency_symbol;
}
Refer:
http://docs.woothemes.com/document/add-a-custom-currency-symbol/
Example
add_filter( 'woocommerce_currencies', 'add_inr_currency' );
add_filter( 'woocommerce_currency_symbol', 'add_inr_currency_symbol' );
function add_inr_currency( $currencies ) {
$currencies['INR'] = 'INR';
return $currencies;
}
function add_inr_currency_symbol( $symbol ) {
$currency = get_option( 'woocommerce_currency' );
switch( $currency ) {
case 'INR': $symbol = 'Rs.'; break;
}
return $symbol;
}
Refer:
http://www.mrova.com/adding-currency-to-woocommerce/
0 comments:
Post a Comment