WooCommerce Custom Currency Generator

Add a currency WooCommerce does not ship with, or change an existing symbol, name and price format, with the filters that make it stick.

Live output

Enable JavaScript to customise; default output below.

Use the real ISO 4217 code. Gateways and accounting exports match on it.

Shown in the currency dropdown in WooCommerce settings.

Printed with every price. Paste the real symbol rather than an HTML entity.

Live preview custom-currency.php
<?php
/**
 * The BDT currency.
 */

/**
 * Adds the currency to the list in WooCommerce settings.
 *
 * @param array $currencies Currency code to name.
 * @return array
 */
function my_store_add_currency( $currencies ) {
	$currencies['BDT'] = __( 'Bangladeshi Taka', 'my-store' );

	return $currencies;
}
add_filter( 'woocommerce_currencies', 'my_store_add_currency' );

/**
 * Sets the symbol printed with every price.
 *
 * @param string $symbol Current symbol.
 * @param string $currency Currency code being formatted.
 * @return string
 */
function my_store_currency_symbol( $symbol, $currency ) {
	if ( 'BDT' === $currency ) {
		$symbol = '৳';
	}

	return $symbol;
}
add_filter( 'woocommerce_currency_symbol', 'my_store_currency_symbol', 10, 2 );

/**
 * Puts the symbol where this currency expects it, whatever the store setting says.
 *
 * @param string $format Current sprintf format.
 * @param string $position Position from the WooCommerce setting.
 * @return string
 */
function my_store_price_format( $format, $position ) {
	if ( 'BDT' !== get_woocommerce_currency() ) {
		return $format;
	}

	return '%1$s&nbsp;%2$s';
}
add_filter( 'woocommerce_price_format', 'my_store_price_format', 10, 2 );

Output is valid and updates as you type.

Add a currency WooCommerce does not ship with, or fix the symbol and position of one it does, with the three filters that actually control how a price is printed.

How to use

  1. Use the real ISO 4217 code. Payment gateways, tax services and accounting exports all match on it, and an invented code fails at the gateway.
  2. Paste the real symbol rather than an HTML entity. WooCommerce escapes output, so &#2547; shows up as those characters on the page.
  3. Turn off “add it to the list” if the currency already exists and you only want a different symbol or position.
  4. Force the format only when this currency needs a different position from the rest of the store. The store setting applies to every currency at once.
  5. Set the decimal places before taking orders. Changing it later does not rewrite totals already stored.

Example

Adding a currency and putting its symbol on the left with a space:

function acme_add_currency( $currencies ) {
	$currencies['BDT'] = __( 'Bangladeshi Taka', 'acme' );

	return $currencies;
}
add_filter( 'woocommerce_currencies', 'acme_add_currency' );

function acme_currency_symbol( $symbol, $currency ) {
	if ( 'BDT' === $currency ) {
		$symbol = '৳';
	}

	return $symbol;
}
add_filter( 'woocommerce_currency_symbol', 'acme_currency_symbol', 10, 2 );

Adding the currency does not select it. Pick it in WooCommerce, Settings, General once the snippet is active.

Pitfalls

  • Adding a currency does not make a gateway accept it. Stripe, PayPal and the rest each publish their own list, and an unsupported currency fails at payment.
  • The symbol filter needs 10, 2 to receive the currency code. Without it you change the symbol for every currency at once.
  • woocommerce_price_format runs for the active currency only in the generated code. Without the code check, one currency’s format leaks into all of them.
  • Changing decimal places does not touch stored order totals. Old orders keep the precision they were created with, which shows up in reports.
  • Exchange rates are not part of this. WooCommerce stores one currency; multi currency needs a plugin that converts and stores rates.
  • An invented currency code breaks tax services and CSV exports that validate against ISO 4217.
  • &nbsp; in the price format is intentional: a normal space lets the symbol wrap onto its own line.
  • Some themes format prices themselves. If the symbol is right in the cart and wrong on the product page, look at the theme first.

Compatibility

woocommerce_currencies, woocommerce_currency_symbol, woocommerce_price_format and wc_get_price_decimals have been stable since WooCommerce 2.4 and still apply in WooCommerce 8 and 9, including the cart and checkout blocks, which format prices through the same helpers. The generated code targets PHP 7.0 and up, and the tool runs entirely in your browser.

Frequently asked questions

Will my payment gateway accept the new currency?
Only if the gateway itself supports it. WooCommerce will happily price in a currency your gateway rejects at checkout.
Can I show prices in two currencies?
Not with these filters. That needs a multi currency plugin that stores rates and converts per customer.
Why is my symbol showing as characters?
You pasted an HTML entity. Paste the actual symbol instead; WooCommerce escapes output.
Do old orders change when I change the symbol?
The symbol is display only, so old orders show the new one. Decimal places are different: those are stored per order.
Where does the currency get selected?
WooCommerce, Settings, General. The snippet only adds it to the list.

From the people who built this tool

WP Adminify

The WordPress admin, rebuilt: a dashboard worth looking at, menu and column control, a real file manager and the login page your client sees.

See WP Adminify Free version on WordPress.org

Weekly drops

New tools, when there are new tools

One email when something worth using ships. No schedule to fill, so no filler.

Your address goes nowhere else, and one click unsubscribes.