Home > widget-integration > FilterFormatHelper > replaceDotCommaZero
FilterFormatHelper.replaceDotCommaZero() method
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.
Signature:
replaceDotCommaZero(str: string): string;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
str |
string |
Formatted price string to process |
Returns:
string
String with trailing ,00 or .00 removed
Example 1
Basic usage:
const cleaned = helper.replaceDotCommaZero('$10.00');
// Returns: "$10"
Example 2
Extend to preserve zeros for specific currencies:
window.boostWidgetIntegration.extend('FilterFormatHelper', (FilterFormatHelper) => {
return class CustomFilterFormatHelper extends FilterFormatHelper {
replaceDotCommaZero(str) {
// Always show decimals for USD
if (this.appService.TAEAppConfig.shop?.currency === 'USD') {
return str;
}
return super.replaceDotCommaZero(str);
}
};
});