Custom Currency Code in WooCommerce: Adding a Non-ISO Currency
Adding a custom currency symbol to WooCommerce is straightforward. Adding a custom currency code became harder in WooCommerce 9.x, which validates codes against the ISO 4217 list and rejects anything outside it.
WooCommerce 9.x implemented strict currency validation using ISO 4217 whitelist. XTR is not a standard ISO currency code, causingwc_create_order() to fail.
Technical Background
XTR (Telegram Stars) is a non-standard currency used within Telegram's payment ecosystem. WooCommerce now validates all currency codes against the official ISO 4217 list before order creation. Previous behavior (WooCommerce < 9.x): Any currency code was accepted Current behavior (WooCommerce 9.x+): Only whitelisted ISO codes are validRegister XTR as Valid Currency
File:functions.php (theme)
Code:
add_filter('woocommerce_currencies', function($currencies) {
$currencies['XTR'] = __('Telegram Stars', 'woocommerce');
return $currencies;
});
add_filter('woocommerce_currency_symbol', function($symbol, $currency) {
if ($currency === 'XTR') {
return '⭐';
}
return $symbol;
}, 10, 2);
Result: XTR becomes selectable in WooCommerce currency list.
The example disclosed in this article may apply to any non-existent currency