• Skip to main content
  • Skip to secondary menu
  • Skip to primary sidebar
  • Skip to footer
SnippetPress

SnippetPress

The Home of WordPress Snippets

Vultr Web Hosting
  • Cheat Sheets
  • Reviews
  • Snippets
  • Tutorials

Add a Custom Currency to WooComerce

June 19, 2020 by SnippetPress Leave a Comment

WooCommerce supports hundreds of currencies, 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 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?

The snippet should be placed 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.

Filed Under: Snippets, Snippets, WooCommerce

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

E-mail Newsletter

More to See

WooCommerce – Prevent Product Being Added To Cart If A Specific Product Is Already In Cart

July 15, 2020 By SnippetPress

WooCommerce – Display an “Add $X To Get Free Shipping” Notice

July 13, 2020 By SnippetPress

Footer

Recent

  • Change The WordPress Page Title Separator Without A Plugin
  • WooCommerce – Prevent Product Being Added To Cart If A Specific Product Is Already In Cart
  • WooCommerce – Display an “Add $X To Get Free Shipping” Notice
  • WooCommerce – Integrate Google Merchant Center Customer Reviews
  • WooCommerce – Disable Out of Stock Variations

Search

Copyright © 2023 ·SnippetPress