When you are customizing WooCommerce, you may want to change the WooCommerce currency code to reflect your custom options. I helps to know where the WooCommerce currency code is located and the various ways you can customize the WooCommerce currency to suit your needs.

In this post, I want to show you all the details about WooCommerce currency code and how you can go about customizing the WooCommerce currency code using specific filters.

WooCommerce Currency Code

WooCommerce Currency symbols and names follow the Unicode CLDR recommendation  and the most important function that controls the WooCommerce currency is 

$array = get_woocommerce_currencies();

This method is located in the following path of the WooCommerce plugin directory :

woocommerce/includes/wc-core-functions.php

You can click on this link to access the  WooCommerce currency code method that controls the functionality of all the currency codes.

WooCommerce Currency Code Custom Code Snippets

You can change the currency symbol using the code snippet below

add_filter( 'woocommerce_currency_symbol', 'tomdesign_change_currency_symbols', 10, 2 );
function tomdesign_change_currency_symbols( $currency_symbols, $currency ) {
    if ( 'USD' === $currency ) {
        return 'USD';
    }
    if ( 'EUR' === $currency ) {
        return 'Euro';
    }
    if ( 'AED' === $currency ) {
        return 'AED';
    }
    return $currency_symbols;
}

Add a Custom Currency or Symbol

You can add a custom WooCommerce currency or add a custom WooCommerce symbol using the code snippets
below :

/**
 * Custom currency and currency symbol
 */
add_filter( 'woocommerce_currencies', 'njengah_add_my_currency' ); 
function njengah_add_my_currency( $currencies ) { 
     $currencies['ABC'] = __( 'Currency name', 'woocommerce' );
     return $currencies;      
} 

add_filter('woocommerce_currency_symbol', 'njengah_add_my_currency_symbol', 10, 2); 
function njengah_add_my_currency_symbol( $currency_symbol, $currency ) { 
     switch( $currency ) {
          case 'ABC': $currency_symbol = '$'; break;
     }
     return $currency_symbol;      
}

Add Currency Code As Suffix To Prices

You can add WooCommerce currency symbol as a price suffix using the code snippet
below :

add_action('woocommerce_price_format', 'tomdesign_add_price_suffix', 1, 2); 
function tomdesign_add_price_suffix($format, $currency_position) { 
    switch ( $currency_position ) {
        case 'left' :
            $currency = get_woocommerce_currency();
            $format = '%1$s%2$s ' . $currency;
        break;
    }  
    return $format;
}

Add Currency Code Before Symbol

A potential solution is to show the currency code before the symbol. This way there isn’t any confusion about the currency. Go ahead and download this mini plugin and install it into your site.

function tomdesign_currency_symbol( $currency_symbol, $currency ) {
    switch( $currency ) {
        case 'USD':
            $currency_symbol = 'USD $';
            break;
        case 'NZD':
            $currency_symbol = 'NZD $';
            break;
        case 'AUD':
            $currency_symbol = 'AUD $';
            break;
    }
    return $currency_symbol;
}
add_filter('woocommerce_currency_symbol', 'tomdesign_currency_symbol', 30, 2);

Use Hook filter change to left position

add_filter( 'woocommerce_price_format', 'custom_price_format', 10, 2 );
function custom_price_format( $format, $curreny_pos ) { 
    if( 'US$' == get_woocommerce_currency_symbol() ) {
        return '%1$s %2$s';
    } 
    return $format;
}

In this post we have shared the different ways you can change the WooCommerce currency using code snippets and the location of the WooCommerce code for the currency to help you understand how WooCommerce currency works as a WooCommerce developer.