Home > widget-integration > CartDrawerRecommendationController > formatPriceIfNeeded
CartDrawerRecommendationController.formatPriceIfNeeded() method
Format price if it appears to be a raw number string. If the price already contains currency symbols or non-numeric characters, it's considered already formatted and returned as-is.
Uses the local formatPrice() method for consistent formatting.
Signature:
protected formatPriceIfNeeded(price: string, showCurrencyCodes?: boolean): string;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
price |
string |
Price string that may be raw number or formatted |
|
showCurrencyCodes |
boolean |
(Optional) Whether to display currency codes (e.g., "USD") alongside the price |
Returns:
string
Formatted price string