Home > widget-integration > FilterFormatHelper > hasMultiVariantPriceFormat
FilterFormatHelper.hasMultiVariantPriceFormat() method
Checks if multi-variant price should be displayed based on translation template.
Determines whether a translation template expects a price range format by checking for {{minPrice}} or {{maxPrice}} placeholders. This is used to conditionally display price ranges like "$10.00 - $20.00" versus single prices. Override this method to customize price range detection logic for shop-specific translation formats.
Signature:
hasMultiVariantPriceFormat(amountTranslation?: string): boolean;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
amountTranslation |
string |
(Optional) The translation template string to check (e.g., "{{minPrice}} - {{maxPrice}}") |
Returns:
boolean
True if translation contains minPrice or maxPrice placeholders, false otherwise
Example 1
Basic usage:
const hasRange = helper.hasMultiVariantPriceFormat('{{minPrice}} - {{maxPrice}}');
// Returns: true
Example 2
Extend to support custom price range placeholders:
window.boostWidgetIntegration.extend('FilterFormatHelper', (FilterFormatHelper) => {
return class CustomFilterFormatHelper extends FilterFormatHelper {
hasMultiVariantPriceFormat(amountTranslation) {
// Also check for custom "fromPrice" and "toPrice" placeholders
if (amountTranslation?.includes('{{fromPrice}}') || amountTranslation?.includes('{{toPrice}}')) {
return true;
}
return super.hasMultiVariantPriceFormat(amountTranslation);
}
};
});