Page 1 of 1

Changing Currency in broadleaf

Posted: Sun Mar 24, 2013 4:30 am
by Sambhav
Hi

I want to change the currency symbol that appears before any cost/price in web pages throughtout the application.

Exploring the code I found that the BLC has a 'blc' thymleaf dialect and associated

Code: Select all

'org.broadleafcommerce.core.web.processor.PriceTextDisplayProcessor

' class for 'price' attribute

So in html files the code is like :-

Code: Select all

<div style="font: 32px/28px 'Oxygen', Helvetica, sans-serif;"[b] [u]blc:price[/u][/b]="${order.total}"></div>


Doubts:-

1. The PriceTextDisplayProcessor class has overridden function getText that seems to be returning hardcoded '$' with the price.

Code: Select all

 if (price == null || price.isZero()) {
         return "$0.00";
      } else {
         return "$" + price.getAmount().toString();
      }


( I could also see a TODO by developer : "// TODO: Actually make the returned text formatted for the given locale"

Is that a bug?!?

2. Where are the beans defined for BLC dialect and processor? How the blc dialect is actually configured and how can I configur my own processor for price attribute

3. How 'Currency Resolution' is connected with this http://docs.broadleafcommerce.org/2.2/Currency-Resolution.html . I just could now connect them.

4. Any quick workaround this problem?

Thanks for you help.

Sambhav

Re: Changin Currency in broadleaf

Posted: Sun Mar 24, 2013 3:02 pm
by bpolster
Kumar,

You will want to upgrade to Broadleaf Commerce 2.2 where the PriceTextDisplayProcessor was enhanced to handle currency formatting.

Information on your other questions:

Broadleaf Commerce provides a set of Thymeleaf Processors collectively known as a BLCDialect. Most are defined in this file on Github.

Creating your own thymeleaf dialect to use with BLC is discussed here.

In 2.2, the key mechanism for setting locale (and generally currency as a result) happens with the BroadleafRequestProcessor

Support for multiple currencies is achieved via the Price List feature that is part of the Broadleaf Commerce commercial module. Showing a single currency can be done using the steps above or perhaps more simply in your case by writing your own Thymeleaf Processor.