Add a Custom Currency to WooComerce

WooCommerce supports hundreds of currencies out the box, but there may be a situation when you need to add your own. It’s really simple to do, and just requires a code snippet.

Let’s say for example you want to add Bitcoin to WooCommerce. The official currency code for Bitcoin is “XBT” and its symbol is “฿”

add_filter( 'woocommerce_currencies', 'snippetpress_add_currency' );
function snippetpress_add_currency( $currencies ) {
    $currencies['XBT'] = __( 'Bitcoin', 'woocommerce' );
    return $currencies;
}

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

All you need to edit in the above snippet is the currency code “XBT”, the currency name “Bitcoin” and the symbol “฿”. Just put whatever you need for your currency in these places.

Now you’ll notice that in the WooCommerce settings, you can now choose your custom currency!

Where to add the snippet?

Whichever snippet you choose to use, you should place it at the bottom of the functions.php file of your child theme. Make sure you know what you’re doing when editing this file. Alternatively, you can use a plugin such as Code Snippets to add the custom code to your WordPress site. If you need further guidance on how to add the code, check out our post on How to Add WordPress Snippets.