Currency formatting in the Aurora starter store
Older WebSphere Commerce starter stores use the FormattedMonetaryAmountDataBean
to
format currencies based on patterns that are defined in the CURFMTDESC database table. The data bean implementation
is easy to customize by updating the default patterns that are defined
in the CURFMTDESC database table. In addition, the patterns can include
images and HTML entities.
The Aurora starter store, however,
uses web services rather than data beans to perform most store functions.
Since the web services do not format currencies, the store uses the JSTL format number tag (<fmt:formatNumber>
)
in JSP files in combination with the shopper's locale setting to format
currencies. As a result, customizing the currency format for Aurora
involves changing the tagging in many JSP files.
The following code snippet is an example of the JSTL implementation that sets the currency format on the shopping cart page of the Aurora store:
<span class="price">
<fmt:formatNumber var="formattedUnitPrice" value="${orderItem.unitPrice}" type="currency"
maxFractionDigits="${env_currencyDecimal}" currencySymbol="${env_CurrencySymbolToFormat}"/>
<c:out value="${formattedUnitPrice}" escapeXml="false" />
<c:out value="${CurrencySymbol}"/>
</span>
Currency customization options
If a shopper is viewing a store with US prices in the French language, the JSTL implementation displays the price according to the currency format for the French locale (fr_FR):1 800,00 $
- Pass the
pattern
attribute of the<fmt:formatNumber>
tag to all JSP files that display prices in the store. - Implement a custom tag. This option still requires an update to all JSP files that display prices. However, if you want to change the pattern in the future, you can change the custom tag itself rather than updating all the JSP files again.