Popular Posts

How to setup a store that supports multiple currencies per language?

Publish a store with multiple languages from admin console.

In general the STORE.SETCURR column determines the selling currency for the store. But what if a store has to support multiple currencies to sell based on the language/country ? Here is a smal POC done to make it work.

Steps:
  • Set up a store that supports multiple languages

  • Set up currency for each language in STORELANG.SETCURR

  • Create a filter (that runs after RunTimeServlet, because only after this the command context will be available). Within the doFilter method of the new filter write the following code to set the currency based on language/locale.
         CommandContext ctx = (CommandContext) httpRequest.getAttribute("CommandContext");
       
         if("-1".equalsIgnoreCase(httpRequest.getParameter("langId"))){
             ctx.setCurrency("USD");
         }else if("-2".equalsIgnoreCase(httpRequest.getParameter("langId"))){
             ctx.setCurrency("CAD");
         }else if("-3".equalsIgnoreCase(httpRequest.getParameter("langId"))){
             ctx.setCurrency("EUR");
         }
  • In each of the order updation commands like, OrderItemAdd/OrderItemUpdate/OrderItemDisplay, add the following parameters in the request properties to recalculate prices when locale is switched.
        prop.put("updatePrices", "1");
        prop.put("doPrice", "Y");
        prop.put("refreshContractAndOffer", "1");
       
Doing the above steps will ensure that the prices are recalculated whenever the user switches between different locales. This method works if different prices are to be setup for different countries/currencies. It doesnt work if we have to setup different prices for the same currency. This is an alternative to setting up multiple stores for each country. In case prices based on region is to be setup, i.e., prices for different states/region of a country, then a price rule has to be created to select the prices from different pricelist (whereas priceslist per region).

No comments:

Post a Comment