You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by "Josip Almasi (JIRA)" <ji...@apache.org> on 2014/09/11 12:22:33 UTC

[jira] [Updated] (OFBIZ-5767) WebShoppingCart ignores session currency

     [ https://issues.apache.org/jira/browse/OFBIZ-5767?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Josip Almasi updated OFBIZ-5767:
--------------------------------
    Description: 
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.

  was:
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 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()!


> 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
>
> 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)