Modify currency symbols used in Alpha Insights price displays.
This filter allows you to customize or replace currency symbols for specific currencies. Useful for displaying custom symbols, adding regional variations, or supporting cryptocurrencies and custom currency codes.
File: includes/functions/wpd-currency-functions.php
Function: wpd_get_woocommerce_currency_symbol()
Line: ~446
| Parameter | Type | Description |
|---|---|---|
| $currency_symbol | string | The currency symbol for the given currency code |
| $currency | string | The three-letter currency code (e.g., 'USD', 'EUR', 'GBP') |
Type: string
Description: Modified currency symbol
add_filter( 'wpd_woocommerce_currency_symbol', 'add_crypto_symbols', 10, 2 );
function add_crypto_symbols( $symbol, $currency )
{
$crypto_symbols = array(
'BTC' => '₿',
'ETH' => 'Ξ',
'LTC' => 'Ł',
'USDT' => '₮',
'DOGE' => 'Ð'
);
if ( isset( $crypto_symbols[$currency] ) )
{
return $crypto_symbols[$currency];
}
return $symbol;
}
add_filter( 'wpd_woocommerce_currency_symbol', 'use_currency_code', 10, 2 );
function use_currency_code( $symbol, $currency )
{
// Display currency code (USD, EUR) instead of symbol ($, €)
return $currency;
}
add_filter( 'wpd_woocommerce_currency_symbol', 'custom_usd_symbol', 10, 2 );
function custom_usd_symbol( $symbol, $currency )
{
// Use "USD $" instead of just "$"
if ( $currency === 'USD' )
{
return 'USD $';
}
// Use custom Euro symbol
if ( $currency === 'EUR' )
{
return 'EUR €';
}
return $symbol;
}
add_filter( 'wpd_woocommerce_currency_symbol', 'regional_symbols', 10, 2 );
function regional_symbols( $symbol, $currency )
{
// Different dollar symbol for different regions
$dollar_currencies = array( 'USD', 'CAD', 'AUD', 'NZD', 'SGD' );
if ( in_array( $currency, $dollar_currencies ) )
{
// Show which dollar it is
return $currency . ' $';
}
return $symbol;
}
add_filter( 'wpd_woocommerce_currency_symbol', 'custom_currency', 10, 2 );
function custom_currency( $symbol, $currency )
{
// Add support for custom internal currency
if ( $currency === 'CREDITS' )
{
return 'CR';
}
if ( $currency === 'POINTS' )
{
return 'P';
}
return $symbol;
}
add_filter( 'wpd_woocommerce_currency_symbol', 'html_symbols', 10, 2 );
function html_symbols( $symbol, $currency )
{
// Add styling or icons to symbols
if ( $currency === 'USD' )
{
return '$';
}
if ( $currency === 'EUR' )
{
return '€';
}
return $symbol;
}
add_filter( 'wpd_woocommerce_currency_symbol', 'prefix_all_symbols', 10, 2 );
function prefix_all_symbols( $symbol, $currency )
{
// In multi-currency stores, always show currency code
$store_currencies = get_option( 'active_currencies', array( 'USD' ) );
if ( count( $store_currencies ) > 1 )
{
return $currency . ' ' . $symbol;
}
return $symbol;
}
add_filter( 'wpd_woocommerce_currency_symbol', 'context_aware_symbol', 10, 2 );
function context_aware_symbol( $symbol, $currency )
{
// In reports, use abbreviated symbol
if ( isset( $_GET['page'] ) && strpos( $_GET['page'], 'reports' ) !== false )
{
$abbreviated = array(
'USD' => '$',
'EUR' => '€',
'GBP' => '£',
'JPY' => '¥'
);
return isset( $abbreviated[$currency] ) ? $abbreviated[$currency] : $currency;
}
return $symbol;
}
Alpha Insights inherits currency symbols from WooCommerce, including:
Currency codes follow ISO 4217 standard:
Common currency symbols and their Unicode:
$ U+0024 Dollar
€ U+20AC Euro
£ U+00A3 Pound
¥ U+00A5 Yen
₹ U+20B9 Indian Rupee
₽ U+20BD Russian Ruble
₿ U+20BF Bitcoin
₺ U+20BA Turkish Lira
₴ U+20B4 Ukrainian Hryvnia
₱ U+20B1 Philippine Peso
/* Style currency symbols */
.currency-usd {
color: #28a745;
font-weight: 600;
}
.currency-eur {
color: #0066cc;
font-weight: 600;
}
.woocommerce-Price-currencySymbol {
font-weight: normal;
opacity: 0.8;
}
add_filter( 'wpd_woocommerce_currency_symbol', 'debug_currency_symbol', 999, 2 );
function debug_currency_symbol( $symbol, $currency )
{
error_log( sprintf(
'Currency: %s | Symbol: %s',
$currency,
$symbol
));
return $symbol;
}
woocommerce_currency_symbols - Modify base currency symbol arraywpd_get_woocommerce_currency_symbol( $currency ) - Get currency symbolwpd_get_store_currency() - Get store's default currencywpd_store_price( $price, $args ) - Format price for display