Home > widget-integration > CartDrawerRecommendationController > formatPrice
CartDrawerRecommendationController.formatPrice() method
Formats a price value according to shop settings and theme configuration.
This method implements the same logic as RecommendationWidgetController.formatPrice() but is duplicated here to avoid circular dependency issues.
Signature:
formatPrice(price: number, showCurrencyCodes?: boolean): string;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
price |
number |
The price value to format (in store currency unit, NOT cents) |
|
showCurrencyCodes |
boolean |
(Optional) Whether to display currency codes (e.g., "USD") alongside the price |
Returns:
string
Formatted price string with currency symbol and shop-specific styling
Example
Override to add custom price formatting for a specific shop:
window.boostWidgetIntegration.extend('CartDrawerRecommendationController', (Base) => {
return class extends Base {
formatPrice(price, showCurrencyCodes) {
// Apply shop-specific rounding before formatting
const roundedPrice = Math.ceil(price);
return super.formatPrice(roundedPrice, showCurrencyCodes);
}
};
});