Home > widget-integration > FilterFormatHelper > formatCurrency
FilterFormatHelper.formatCurrency() method
Formats a currency value according to shop settings.
This method applies shop-specific currency formatting using Shopify's money_format or money_format_with_currency configuration. It supports various display options including currency codes, superscript cents, and decimal removal. Override this method to implement custom formatting rules for specific shops or currencies.
Signature:
formatCurrency(options: {
value: number | string | null | undefined;
showCurrencyCodes?: boolean;
showCentAsSuperscript?: boolean;
removeDecimalPoint?: boolean;
isPriceCompare?: boolean;
removePriceDecimal?: boolean;
}): string | null;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
options |
{ value: number | string | null | undefined; showCurrencyCodes?: boolean; showCentAsSuperscript?: boolean; removeDecimalPoint?: boolean; isPriceCompare?: boolean; removePriceDecimal?: boolean; } |
Formatting options object |
Returns:
string | null
Formatted currency string according to shop settings, or null if value is null/undefined
Example 1
Basic usage:
const formatted = helper.formatCurrency({ value: 1999, showCurrencyCodes: true });
// Returns: "$19.99 USD" (based on shop configuration)
Example 2
Extend for custom currency rounding:
window.boostWidgetIntegration.extend('FilterFormatHelper', (FilterFormatHelper) => {
return class CustomFilterFormatHelper extends FilterFormatHelper {
formatCurrency(options) {
// Round JPY to nearest whole number
if (this.appService.TAEAppConfig.shop?.currency === 'JPY') {
options.removePriceDecimal = true;
options.value = Math.round(Number(options.value));
}
return super.formatCurrency(options);
}
};
});