How to Add a Custom Currency Symbol in WooCommerce?

Do you want to add a custom currency and currency symbol in WooCommerce?

WooCommerce comes with a long list of in-built currencies from across the world. But still, it’s possible that you may not find your currency.

In this case, WooCommerce allows you to add your custom currency to your WooCommerce website.

You can easily add a custom currency symbol in WooCommerce using the below code.

/**
 * Add Custom Currency Name
 */
function maverick_add_custom_currency_woocommerce( $currencies ) {
    $currencies['ABC'] = __( 'Currency name', 'woocommerce' );
    return $currencies;
}

add_filter( 'woocommerce_currencies', 'maverick_add_custom_currency_woocommerce' );

/**
 * Add Custom Currency Symbol
 */
function maverick_add_custom_currency_symbol_woocommerce( $currency_symbol, $currency ) {
    switch( $currency ) {
        case 'ABC': $currency_symbol = '$'; break;
    }
    return $currency_symbol;
}

add_filter('woocommerce_currency_symbol', 'maverick_add_custom_currency_woocommerce', 10, 2);

In the above code, you must replace the below details with your currency details.

  1. Replace ‘ABC’ with your custom currency – Here, ABC represents a unique ID for your currency and WooCommerce uses it to identify it across the system. For example, if I want to add a custom currency ‘unmaskwp’, and the ID becomes ‘unmaskwp’.
  2. Replace ‘Currency name’ with your currency name – This is the name for your currency. For example, I will name my currency ‘UnmaskWP’.
  3. Replace ‘$’ with your currency symbol – This is the currency symbol that will be displayed along with the product price. For example, I will be using ‘#’ as my currency symbol.

With the above changes. the code will be revised to the below code.

/**
 * Add Custom Currency Name
 */
function maverick_add_custom_currency_woocommerce( $currencies ) {
    $currencies['unmaskwp'] = __( 'UnmaskWP', 'woocommerce' );
    return $currencies;
}

add_filter( 'woocommerce_currencies', 'maverick_add_custom_currency_woocommerce' );

/**
 * Add Custom Currency Symbol
 */
function maverick_add_custom_currency_symbol_woocommerce( $currency_symbol, $currency ) {
    switch( $currency ) {
        case 'unmaskwp': $currency_symbol = '#'; break;
    }
    return $currency_symbol;
}

add_filter('woocommerce_currency_symbol', 'maverick_add_custom_currency_woocommerce', 10, 2);

Leave a Reply

Your email address will not be published. Required fields are marked *