Home > widget-integration > FilterFormatHelper
FilterFormatHelper class
Signature:
export declare class FilterFormatHelper
Constructors
|
Constructor |
Modifiers |
Description |
|---|---|---|
|
Constructs a new instance of the |
Methods
|
Method |
Modifiers |
Description |
|---|---|---|
|
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. | ||
|
Formats money value according to specified format options. This is the core formatting method that applies Shopify money format templates (e.g., "${{amount}}", "{{amount}} USD") to numeric values. It handles various format types including amount, amount_no_decimals, amount_with_comma_separator, etc. Override this method to customize the fundamental money formatting logic. | ||
|
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. | ||
|
Checks if price transformation has already been applied to element. Prevents duplicate price formatting by checking for a data attribute flag on the DOM element. This is crucial for avoiding multiple transformations when price elements are re-rendered. Override this method to implement custom transformation tracking logic or use different attribute naming conventions. | ||
|
isSamePrice(priceMin, priceMax, compareAtPriceMin, compareAtPriceMax) |
Checks if product has same min and max prices. Determines whether a product's price range should be collapsed to a single price by comparing both the regular prices and compare-at prices. This is useful for deciding whether to show "$10.00" versus "$10.00 - $15.00". Override this method to implement custom price comparison logic, such as tolerance-based matching. | |
|
Validates if HTML contains actual price data (has digits). Ensures that price HTML contains numeric data before processing. This prevents attempting to format empty or placeholder content. Override this method to implement more sophisticated validation logic, such as checking for specific currency symbols or price format patterns. | ||
|
Replaces trailing ,00 or .00 with empty string. Removes trailing zero decimals from formatted prices for cleaner display (e.g., "$10.00" becomes "$10"). This is commonly used when withTrailingZeros is false. Override this method to customize zero decimal removal logic, such as preserving certain patterns or handling different decimal formats. |