Alpha Insights uses several standard WooCommerce filters to ensure compatibility and consistent behavior with WooCommerce core.
These are native WooCommerce filters that Alpha Insights respects and utilizes. They are documented here for reference when customizing price display and currency handling in Alpha Insights.
Filter the raw numeric price value before any formatting is applied. This is the first filter in the price formatting pipeline.
File: includes/wpd-functions.php
Function: wpd_store_price()
Line: ~1158
| Parameter | Type | Description |
|---|---|---|
| $raw_price | float | Raw price value (absolute value if negative) |
| $original_price | float|string | Original price before processing |
add_filter( 'raw_woocommerce_price', 'modify_raw_price', 10, 2 );
function modify_raw_price( $price, $original_price )
{
// Round to nearest dollar
if ( abs( $price ) > 100 )
{
return round( $price, 0 );
}
return $price;
}
Filter the price after it has been formatted with thousands separators and decimal places, but before HTML markup is added.
File: includes/wpd-functions.php
Function: wpd_store_price()
Line: ~1170
| Parameter | Type | Description |
|---|---|---|
| $formatted_price | string | Formatted price string (e.g., "1,234.56") |
| $price | float | Unformatted price value |
| $decimals | int | Number of decimal places |
| $decimal_separator | string | Decimal separator character |
| $thousand_separator | string | Thousand separator character |
| $original_price | float|string | Original price value |
add_filter( 'formatted_woocommerce_price', 'customize_formatted_price', 10, 6 );
function customize_formatted_price( $formatted, $price, $decimals, $dec_sep, $thou_sep, $original )
{
// Add custom thousand separator styling
$formatted = str_replace( $thou_sep, '' . $thou_sep . '', $formatted );
return $formatted;
}
Control whether trailing zeros after the decimal point should be removed from prices.
File: includes/wpd-functions.php
Function: wpd_store_price()
Line: ~1172
| Parameter | Type | Description |
|---|---|---|
| $trim_zeros | bool | Whether to trim trailing zeros (default: false) |
add_filter( 'woocommerce_price_trim_zeros', '__return_true' );
Result:
add_filter( 'woocommerce_price_trim_zeros', 'conditional_trim_zeros' );
function conditional_trim_zeros( $trim )
{
// Only trim zeros for whole dollar amounts
global $current_price;
if ( isset( $current_price ) && floor( $current_price ) == $current_price )
{
return true;
}
return false;
}
Modify the complete array of currency symbols used by WooCommerce and Alpha Insights.
File: includes/functions/wpd-currency-functions.php
Function: wpd_get_woocommerce_currency_symbol()
Line: ~279
| Parameter | Type | Description |
|---|---|---|
| $symbols | array | Associative array of currency codes to symbols |
add_filter( 'woocommerce_currency_symbols', 'add_custom_currencies' );
function add_custom_currencies( $symbols )
{
// Add cryptocurrencies
$symbols['BTC'] = '฿';
$symbols['ETH'] = 'Ξ';
// Add custom internal currency
$symbols['CREDITS'] = 'CR';
// Modify existing symbol
$symbols['USD'] = 'US$';
return $symbols;
}
add_filter( 'woocommerce_currency_symbols', 'use_currency_codes' );
function use_currency_codes( $symbols )
{
// Replace all symbols with their currency codes
foreach ( $symbols as $code => $symbol )
{
$symbols[$code] = $code;
}
return $symbols;
}
These filters are applied in this order during price formatting:
raw_woocommerce_price - Modify raw numberformatted_woocommerce_price - Modify formatted stringwoocommerce_price_trim_zeros - Trim zeros if enabledwpd_price - Final HTML output (Alpha Insights specific)wpd_*) when possible// Log all price filter stages
add_filter( 'raw_woocommerce_price', 'debug_raw_price', 999, 2 );
function debug_raw_price( $price, $original )
{
error_log( '1. Raw Price: ' . $price );
return $price;
}
add_filter( 'formatted_woocommerce_price', 'debug_formatted_price', 999, 6 );
function debug_formatted_price( $formatted, $price, $decimals, $dec_sep, $thou_sep, $original )
{
error_log( '2. Formatted Price: ' . $formatted );
return $formatted;
}
add_filter( 'wpd_price', 'debug_final_price', 999, 5 );
function debug_final_price( $return, $price, $args, $unformatted, $original )
{
error_log( '3. Final HTML: ' . $return );
return $return;
}
For more information about these filters, see: