[ 
https://issues.apache.org/jira/browse/OFBIZ-5767?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14266350#comment-14266350
 ] 

Jacques Le Roux commented on OFBIZ-5767:
----------------------------------------

This is maybe OK for ecommerce (I did not test, but I guess both of you did), 
but not for order manager or direct storeOrder service use. There are (at 
least) 2 cases where it introduces issues. Both implies having a store with a 
non USD currency and prices set only in this non USD currency. 
* If you use the storeOrder service w/o the OFBiz UI then, since 
UtilHttp.getCurrency() will at some point when no currency is set yet 
ultimately refers to currency.uom.id.default which is by default USD you will 
set the session currency to USD and you are trapped.
* Even in the case above, if you use order manager, you can't change the 
currency in the 2nd screen of of order creation. Actually you can put it will 
not be taken into accout, USD will stay.

If you have only 1 currency for all stores, an obvious solution is to set 
currency.uom.id.default to this currency. I did not find an obvious solution 
for stores with different currencies yet. Anyway I don't like to be forced to 
create a patch for that, still investigating other solutions...

> WebShoppingCart ignores session currency
> ----------------------------------------
>
>                 Key: OFBIZ-5767
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-5767
>             Project: OFBiz
>          Issue Type: Bug
>          Components: specialpurpose/ecommerce
>    Affects Versions: 12.04.04, 12.04.05
>            Reporter: Josip Almasi
>            Assignee: Ashish Vijaywargiya
>             Fix For: 14.12.01, 12.04.06, 13.07.02
>
>         Attachments: shoppingcart-currency.patch
>
>
> This is how WebShoppingCart constructor calls ShoppingCart constructor:
> (currencyUom != null ? currencyUom : 
> ProductStoreWorker.getStoreCurrencyUomId(request)),
> WebShoppingCart constructor is called only from 
> getCartObject(HttpServletRequest request, Locale locale, String currencyUom)
> which is called only from
> getCartObject(HttpServletRequest request)
> with null locale and currency.
> So, during WebShoppingCart creation, currency is always set to 
> ProductStoreWorker.getStoreCurrencyUomId(request)
> This method in turn calls UtilHttp.getCurrencyUom(), which makes a number of 
> attempts to find proper currency, with first attempt being session attribute 
> "currencyUom".
> This is a chicken-egg problem though: first-time user does not have 
> currencyUom attribute set, and WebShoppingCart is created immediatelly.
> But once created, nothing ever calls ShoppingCart.setCurrency()!
> The bug is in ShoppingCartEvents.getCartObject():
>         if (cart == null) {
>             cart = new WebShoppingCart(request, locale, currencyUom);
>             session.setAttribute("shoppingCart", cart);
>         } else {
>             if (locale != null && !locale.equals(cart.getLocale())) {
>                 cart.setLocale(locale);
>             }
>             if (currencyUom != null && 
> !currencyUom.equals(cart.getCurrency())) {
> Well, currencyUom parameter is always null.
> If null, it needs to be taken from request parameter, or even better, to go 
> thru entire UtilHttp.getCurrency() thing.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to