Home > widget-integration > FilterController > initCurrencyForFilterPrice

FilterController.initCurrencyForFilterPrice() method

Initializes currency formatting for price filter options. Sets the money format value on price and variant price filter options.

Determines whether to use money format with currency codes (e.g., "$10.00 USD") or without (e.g., "$10.00") based on theme settings, then applies the formatted value to price-type filter options.

Signature:

initCurrencyForFilterPrice(): void;

Returns:

void

Remarks

This method prepares price filter options with the correct money format before rendering. The format is stripped of HTML tags to ensure clean display in filter UI.

Example

Override to add custom price formatting per filter option:

window.boostWidgetIntegration.extend('FilterController', (FilterController) => {
  return class CustomFilterController extends FilterController {
    initCurrencyForFilterPrice() {
      super.initCurrencyForFilterPrice();

      const filter = this.filterStore.state.value.filter;
      filter?.options?.forEach(option => {
        if (option.filterType === 'price') {
          // Add custom currency symbol for specific markets
          if (this.isEUMarket()) {
            option.moneyFormatValue = '€';
          }
        }
      });
    }
  };
});