Set currency dynamically on ecommerce

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Set currency dynamically on ecommerce

Abhishake Agarwal
Hi,

I want to know whether it is possible to set currency dynamically.

Suppose on ecommerce application, I have a currency options and if user
select any of the type of currency, application should set that currency for
that user.

Regards,
Abhishake
Reply | Threaded
Open this post in threaded view
|

Re: Set currency dynamically on ecommerce

Abhishake Agarwal
Hi,

I tried following URL to set currency but it is not working

http://demo.hotwaxmedia.com/ecommerce/control/setSessionCurrencyUom?currencyUom=INR

Regards,
Abhishake

On Sun, Oct 5, 2008 at 10:36 PM, Abhishake Agarwal <
[hidden email]> wrote:

> Hi,
>
> I want to know whether it is possible to set currency dynamically.
>
> Suppose on ecommerce application, I have a currency options and if user
> select any of the type of currency, application should set that currency for
> that user.
>
> Regards,
> Abhishake
>
Reply | Threaded
Open this post in threaded view
|

Re: Set currency dynamically on ecommerce

Jacques Le Roux
Administrator
I also tried in UI (nothing happens as far as I can tell), and looked after at the code. I ran out of time but it seems that OOTB
only the Product Store Currency is taken into account (through ProductStoreWorker.getStoreCurrencyUomId when the
WebShoppingCart is created). So you would have to re-create your WebShoppingCart passing your currency from the Session

Please use rather user ML for such questions :
http://docs.ofbiz.org/display/OFBADMIN/Mailing+Lists#MailingLists-DeveloperList:dev@...

Thanks

Jacques

From: "Abhishake Agarwal" <[hidden email]>

> Hi,
>
> I tried following URL to set currency but it is not working
>
> http://demo.hotwaxmedia.com/ecommerce/control/setSessionCurrencyUom?currencyUom=INR
>
> Regards,
> Abhishake
>
> On Sun, Oct 5, 2008 at 10:36 PM, Abhishake Agarwal <
> [hidden email]> wrote:
>
>> Hi,
>>
>> I want to know whether it is possible to set currency dynamically.
>>
>> Suppose on ecommerce application, I have a currency options and if user
>> select any of the type of currency, application should set that currency for
>> that user.
>>
>> Regards,
>> Abhishake
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Set currency dynamically on ecommerce

Abhishake Agarwal
Hi,

I have resolved the issue actually currency should be set to shopping cart
object also.

I have modified the setSessionCurrencyUom method as below and it was working
fine

public static String setSessionCurrencyUom(HttpServletRequest request,
HttpServletResponse response) {
        String currencyUom = request.getParameter("currencyUom");
        LocalDispatcher dispatcher = (LocalDispatcher)
request.getAttribute("dispatcher");
        if (UtilValidate.isNotEmpty(currencyUom)) {
            // update the session
            UtilHttp.setCurrencyUom(request.getSession(), currencyUom);

            // update the UserLogin object
            GenericValue userLogin = (GenericValue)
request.getSession().getAttribute("userLogin");
            if (userLogin == null) {
                userLogin = (GenericValue)
request.getSession().getAttribute("autoUserLogin");
            }

            if (userLogin != null) {
                GenericValue ulUpdate = GenericValue.create(userLogin);
                ulUpdate.set("lastCurrencyUom", currencyUom);
                try {
                    ulUpdate.store();
                    userLogin.refreshFromCache();

                } catch (GenericEntityException e) {
                    Debug.logWarning(e, module);
                }
                ShoppingCart cart =
ShoppingCartEvents.getCartObject(request);
                try {
                    cart.setCurrency(dispatcher,currencyUom);
                } catch (CartItemModifyException e) {
                    Debug.logWarning(e, module);
                }
            }
        }
        return "success";
    }

Regards,
Abhishake

On Mon, Oct 13, 2008 at 2:16 AM, Jacques Le Roux <
[hidden email]> wrote:

> I also tried in UI (nothing happens as far as I can tell), and looked after
> at the code. I ran out of time but it seems that OOTB only the Product Store
> Currency is taken into account (through
> ProductStoreWorker.getStoreCurrencyUomId when the
> WebShoppingCart is created). So you would have to re-create your
> WebShoppingCart passing your currency from the Session
>
> Please use rather user ML for such questions :
>
> http://docs.ofbiz.org/display/OFBADMIN/Mailing+Lists#MailingLists-DeveloperList:dev@...
>
> Thanks
>
> Jacques
>
> From: "Abhishake Agarwal" <[hidden email]>
>
>  Hi,
>>
>> I tried following URL to set currency but it is not working
>>
>>
>> http://demo.hotwaxmedia.com/ecommerce/control/setSessionCurrencyUom?currencyUom=INR
>>
>> Regards,
>> Abhishake
>>
>> On Sun, Oct 5, 2008 at 10:36 PM, Abhishake Agarwal <
>> [hidden email]> wrote:
>>
>>  Hi,
>>>
>>> I want to know whether it is possible to set currency dynamically.
>>>
>>> Suppose on ecommerce application, I have a currency options and if user
>>> select any of the type of currency, application should set that currency
>>> for
>>> that user.
>>>
>>> Regards,
>>> Abhishake
>>>
>>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Set currency dynamically on ecommerce

Abhishake Agarwal
Hi,

I have one more query related to this,

Suppose I changed currency from $ to £ now all products prices, whose
currencies has been configured in £ will be displayed.

Problem come when we are on checkout screen as for shipping method cost is
configured with single currency.

example: if shipping method cost is 20 $ then it will display 20 £ which is
incorrect (its just change the sign not the value).

Please let me know is there a fix to it.

Regards,
Abhishake

On Mon, Oct 13, 2008 at 10:36 AM, Abhishake Agarwal <
[hidden email]> wrote:

> Hi,
>
> I have resolved the issue actually currency should be set to shopping cart
> object also.
>
> I have modified the setSessionCurrencyUom method as below and it was
> working fine
>
> public static String setSessionCurrencyUom(HttpServletRequest request,
> HttpServletResponse response) {
>         String currencyUom = request.getParameter("currencyUom");
>         LocalDispatcher dispatcher = (LocalDispatcher)
> request.getAttribute("dispatcher");
>         if (UtilValidate.isNotEmpty(currencyUom)) {
>             // update the session
>             UtilHttp.setCurrencyUom(request.getSession(), currencyUom);
>
>             // update the UserLogin object
>             GenericValue userLogin = (GenericValue)
> request.getSession().getAttribute("userLogin");
>             if (userLogin == null) {
>                 userLogin = (GenericValue)
> request.getSession().getAttribute("autoUserLogin");
>             }
>
>             if (userLogin != null) {
>                 GenericValue ulUpdate = GenericValue.create(userLogin);
>                 ulUpdate.set("lastCurrencyUom", currencyUom);
>                 try {
>                     ulUpdate.store();
>                     userLogin.refreshFromCache();
>
>                 } catch (GenericEntityException e) {
>                     Debug.logWarning(e, module);
>                 }
>                 ShoppingCart cart =
> ShoppingCartEvents.getCartObject(request);
>                 try {
>                     cart.setCurrency(dispatcher,currencyUom);
>                 } catch (CartItemModifyException e) {
>                     Debug.logWarning(e, module);
>                 }
>             }
>         }
>         return "success";
>     }
>
> Regards,
> Abhishake
>
>
> On Mon, Oct 13, 2008 at 2:16 AM, Jacques Le Roux <
> [hidden email]> wrote:
>
>> I also tried in UI (nothing happens as far as I can tell), and looked
>> after at the code. I ran out of time but it seems that OOTB only the Product
>> Store Currency is taken into account (through
>> ProductStoreWorker.getStoreCurrencyUomId when the
>> WebShoppingCart is created). So you would have to re-create your
>> WebShoppingCart passing your currency from the Session
>>
>> Please use rather user ML for such questions :
>>
>> http://docs.ofbiz.org/display/OFBADMIN/Mailing+Lists#MailingLists-DeveloperList:dev@...
>>
>> Thanks
>>
>> Jacques
>>
>> From: "Abhishake Agarwal" <[hidden email]>
>>
>>  Hi,
>>>
>>> I tried following URL to set currency but it is not working
>>>
>>>
>>> http://demo.hotwaxmedia.com/ecommerce/control/setSessionCurrencyUom?currencyUom=INR
>>>
>>> Regards,
>>> Abhishake
>>>
>>> On Sun, Oct 5, 2008 at 10:36 PM, Abhishake Agarwal <
>>> [hidden email]> wrote:
>>>
>>>  Hi,
>>>>
>>>> I want to know whether it is possible to set currency dynamically.
>>>>
>>>> Suppose on ecommerce application, I have a currency options and if user
>>>> select any of the type of currency, application should set that currency
>>>> for
>>>> that user.
>>>>
>>>> Regards,
>>>> Abhishake
>>>>
>>>>
>>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Set currency dynamically on ecommerce

Jacques Le Roux
Administrator
How did you resolve the import issues with org.ofbiz.order.shoppingcart package ?
I guess it's the reason while it's not done OOTB in CommonEvents.setSessionCurrencyUom

Jacques

From: "Abhishake Agarwal" <[hidden email]>
Hi,

I have one more query related to this,

Suppose I changed currency from $ to £ now all products prices, whose
currencies has been configured in £ will be displayed.

Problem come when we are on checkout screen as for shipping method cost is
configured with single currency.

example: if shipping method cost is 20 $ then it will display 20 £ which is
incorrect (its just change the sign not the value).

Please let me know is there a fix to it.

Regards,
Abhishake

On Mon, Oct 13, 2008 at 10:36 AM, Abhishake Agarwal <
[hidden email]> wrote:

> Hi,
>
> I have resolved the issue actually currency should be set to shopping cart
> object also.
>
> I have modified the setSessionCurrencyUom method as below and it was
> working fine
>
> public static String setSessionCurrencyUom(HttpServletRequest request,
> HttpServletResponse response) {
>         String currencyUom = request.getParameter("currencyUom");
>         LocalDispatcher dispatcher = (LocalDispatcher)
> request.getAttribute("dispatcher");
>         if (UtilValidate.isNotEmpty(currencyUom)) {
>             // update the session
>             UtilHttp.setCurrencyUom(request.getSession(), currencyUom);
>
>             // update the UserLogin object
>             GenericValue userLogin = (GenericValue)
> request.getSession().getAttribute("userLogin");
>             if (userLogin == null) {
>                 userLogin = (GenericValue)
> request.getSession().getAttribute("autoUserLogin");
>             }
>
>             if (userLogin != null) {
>                 GenericValue ulUpdate = GenericValue.create(userLogin);
>                 ulUpdate.set("lastCurrencyUom", currencyUom);
>                 try {
>                     ulUpdate.store();
>                     userLogin.refreshFromCache();
>
>                 } catch (GenericEntityException e) {
>                     Debug.logWarning(e, module);
>                 }
>                 ShoppingCart cart =
> ShoppingCartEvents.getCartObject(request);
>                 try {
>                     cart.setCurrency(dispatcher,currencyUom);
>                 } catch (CartItemModifyException e) {
>                     Debug.logWarning(e, module);
>                 }
>             }
>         }
>         return "success";
>     }
>
> Regards,
> Abhishake
>
>
> On Mon, Oct 13, 2008 at 2:16 AM, Jacques Le Roux <
> [hidden email]> wrote:
>
>> I also tried in UI (nothing happens as far as I can tell), and looked
>> after at the code. I ran out of time but it seems that OOTB only the Product
>> Store Currency is taken into account (through
>> ProductStoreWorker.getStoreCurrencyUomId when the
>> WebShoppingCart is created). So you would have to re-create your
>> WebShoppingCart passing your currency from the Session
>>
>> Please use rather user ML for such questions :
>>
>> http://docs.ofbiz.org/display/OFBADMIN/Mailing+Lists#MailingLists-DeveloperList:dev@...
>>
>> Thanks
>>
>> Jacques
>>
>> From: "Abhishake Agarwal" <[hidden email]>
>>
>>  Hi,
>>>
>>> I tried following URL to set currency but it is not working
>>>
>>>
>>> http://demo.hotwaxmedia.com/ecommerce/control/setSessionCurrencyUom?currencyUom=INR
>>>
>>> Regards,
>>> Abhishake
>>>
>>> On Sun, Oct 5, 2008 at 10:36 PM, Abhishake Agarwal <
>>> [hidden email]> wrote:
>>>
>>>  Hi,
>>>>
>>>> I want to know whether it is possible to set currency dynamically.
>>>>
>>>> Suppose on ecommerce application, I have a currency options and if user
>>>> select any of the type of currency, application should set that currency
>>>> for
>>>> that user.
>>>>
>>>> Regards,
>>>> Abhishake
>>>>
>>>>
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Set currency dynamically on ecommerce

Abhishake Agarwal
Hi Jacques,

Actually all our code resides in hot-deploy, when ever we require change in
any of the files, we copy the file to hot-deploy desired path, so I haven't
faced any import issues.

Regards,
Abhishake

On Mon, Oct 13, 2008 at 7:13 PM, Jacques Le Roux <
[hidden email]> wrote:

> How did you resolve the import issues with org.ofbiz.order.shoppingcart
> package ?
> I guess it's the reason while it's not done OOTB in
> CommonEvents.setSessionCurrencyUom
>
>
> Jacques
>
> From: "Abhishake Agarwal" <[hidden email]>
> Hi,
>
> I have one more query related to this,
>
> Suppose I changed currency from $ to £ now all products prices, whose
> currencies has been configured in £ will be displayed.
>
> Problem come when we are on checkout screen as for shipping method cost is
> configured with single currency.
>
> example: if shipping method cost is 20 $ then it will display 20 £ which is
> incorrect (its just change the sign not the value).
>
> Please let me know is there a fix to it.
>
> Regards,
> Abhishake
>
> On Mon, Oct 13, 2008 at 10:36 AM, Abhishake Agarwal <
> [hidden email]> wrote:
>
>  Hi,
>>
>> I have resolved the issue actually currency should be set to shopping cart
>> object also.
>>
>> I have modified the setSessionCurrencyUom method as below and it was
>> working fine
>>
>> public static String setSessionCurrencyUom(HttpServletRequest request,
>> HttpServletResponse response) {
>>        String currencyUom = request.getParameter("currencyUom");
>>        LocalDispatcher dispatcher = (LocalDispatcher)
>> request.getAttribute("dispatcher");
>>        if (UtilValidate.isNotEmpty(currencyUom)) {
>>            // update the session
>>            UtilHttp.setCurrencyUom(request.getSession(), currencyUom);
>>
>>            // update the UserLogin object
>>            GenericValue userLogin = (GenericValue)
>> request.getSession().getAttribute("userLogin");
>>            if (userLogin == null) {
>>                userLogin = (GenericValue)
>> request.getSession().getAttribute("autoUserLogin");
>>            }
>>
>>            if (userLogin != null) {
>>                GenericValue ulUpdate = GenericValue.create(userLogin);
>>                ulUpdate.set("lastCurrencyUom", currencyUom);
>>                try {
>>                    ulUpdate.store();
>>                    userLogin.refreshFromCache();
>>
>>                } catch (GenericEntityException e) {
>>                    Debug.logWarning(e, module);
>>                }
>>                ShoppingCart cart =
>> ShoppingCartEvents.getCartObject(request);
>>                try {
>>                    cart.setCurrency(dispatcher,currencyUom);
>>                } catch (CartItemModifyException e) {
>>                    Debug.logWarning(e, module);
>>                }
>>            }
>>        }
>>        return "success";
>>    }
>>
>> Regards,
>> Abhishake
>>
>>
>> On Mon, Oct 13, 2008 at 2:16 AM, Jacques Le Roux <
>> [hidden email]> wrote:
>>
>>  I also tried in UI (nothing happens as far as I can tell), and looked
>>> after at the code. I ran out of time but it seems that OOTB only the
>>> Product
>>> Store Currency is taken into account (through
>>> ProductStoreWorker.getStoreCurrencyUomId when the
>>> WebShoppingCart is created). So you would have to re-create your
>>> WebShoppingCart passing your currency from the Session
>>>
>>> Please use rather user ML for such questions :
>>>
>>>
>>> http://docs.ofbiz.org/display/OFBADMIN/Mailing+Lists#MailingLists-DeveloperList:dev@...
>>>
>>> Thanks
>>>
>>> Jacques
>>>
>>> From: "Abhishake Agarwal" <[hidden email]>
>>>
>>>  Hi,
>>>
>>>>
>>>> I tried following URL to set currency but it is not working
>>>>
>>>>
>>>>
>>>> http://demo.hotwaxmedia.com/ecommerce/control/setSessionCurrencyUom?currencyUom=INR
>>>>
>>>> Regards,
>>>> Abhishake
>>>>
>>>> On Sun, Oct 5, 2008 at 10:36 PM, Abhishake Agarwal <
>>>> [hidden email]> wrote:
>>>>
>>>>  Hi,
>>>>
>>>>>
>>>>> I want to know whether it is possible to set currency dynamically.
>>>>>
>>>>> Suppose on ecommerce application, I have a currency options and if user
>>>>> select any of the type of currency, application should set that
>>>>> currency
>>>>> for
>>>>> that user.
>>>>>
>>>>> Regards,
>>>>> Abhishake
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Set currency dynamically on ecommerce

Jacques Le Roux
Administrator
Yes this makes sense indeed

But to avoid such confusion, please use rather user ML. The dev ML is about developing OFBiz OOTB, not using it.
This is explained here
http://docs.ofbiz.org/display/OFBADMIN/Mailing+Lists#MailingLists-DeveloperList:dev@...

Thanks
Jacques

From: "Abhishake Agarwal" <[hidden email]>
Hi Jacques,

Actually all our code resides in hot-deploy, when ever we require change in
any of the files, we copy the file to hot-deploy desired path, so I haven't
faced any import issues.

Regards,
Abhishake

On Mon, Oct 13, 2008 at 7:13 PM, Jacques Le Roux <
[hidden email]> wrote:

> How did you resolve the import issues with org.ofbiz.order.shoppingcart
> package ?
> I guess it's the reason while it's not done OOTB in
> CommonEvents.setSessionCurrencyUom
>
>
> Jacques
>
> From: "Abhishake Agarwal" <[hidden email]>
> Hi,
>
> I have one more query related to this,
>
> Suppose I changed currency from $ to £ now all products prices, whose
> currencies has been configured in £ will be displayed.
>
> Problem come when we are on checkout screen as for shipping method cost is
> configured with single currency.
>
> example: if shipping method cost is 20 $ then it will display 20 £ which is
> incorrect (its just change the sign not the value).
>
> Please let me know is there a fix to it.
>
> Regards,
> Abhishake
>
> On Mon, Oct 13, 2008 at 10:36 AM, Abhishake Agarwal <
> [hidden email]> wrote:
>
>  Hi,
>>
>> I have resolved the issue actually currency should be set to shopping cart
>> object also.
>>
>> I have modified the setSessionCurrencyUom method as below and it was
>> working fine
>>
>> public static String setSessionCurrencyUom(HttpServletRequest request,
>> HttpServletResponse response) {
>>        String currencyUom = request.getParameter("currencyUom");
>>        LocalDispatcher dispatcher = (LocalDispatcher)
>> request.getAttribute("dispatcher");
>>        if (UtilValidate.isNotEmpty(currencyUom)) {
>>            // update the session
>>            UtilHttp.setCurrencyUom(request.getSession(), currencyUom);
>>
>>            // update the UserLogin object
>>            GenericValue userLogin = (GenericValue)
>> request.getSession().getAttribute("userLogin");
>>            if (userLogin == null) {
>>                userLogin = (GenericValue)
>> request.getSession().getAttribute("autoUserLogin");
>>            }
>>
>>            if (userLogin != null) {
>>                GenericValue ulUpdate = GenericValue.create(userLogin);
>>                ulUpdate.set("lastCurrencyUom", currencyUom);
>>                try {
>>                    ulUpdate.store();
>>                    userLogin.refreshFromCache();
>>
>>                } catch (GenericEntityException e) {
>>                    Debug.logWarning(e, module);
>>                }
>>                ShoppingCart cart =
>> ShoppingCartEvents.getCartObject(request);
>>                try {
>>                    cart.setCurrency(dispatcher,currencyUom);
>>                } catch (CartItemModifyException e) {
>>                    Debug.logWarning(e, module);
>>                }
>>            }
>>        }
>>        return "success";
>>    }
>>
>> Regards,
>> Abhishake
>>
>>
>> On Mon, Oct 13, 2008 at 2:16 AM, Jacques Le Roux <
>> [hidden email]> wrote:
>>
>>  I also tried in UI (nothing happens as far as I can tell), and looked
>>> after at the code. I ran out of time but it seems that OOTB only the
>>> Product
>>> Store Currency is taken into account (through
>>> ProductStoreWorker.getStoreCurrencyUomId when the
>>> WebShoppingCart is created). So you would have to re-create your
>>> WebShoppingCart passing your currency from the Session
>>>
>>> Please use rather user ML for such questions :
>>>
>>>
>>> http://docs.ofbiz.org/display/OFBADMIN/Mailing+Lists#MailingLists-DeveloperList:dev@...
>>>
>>> Thanks
>>>
>>> Jacques
>>>
>>> From: "Abhishake Agarwal" <[hidden email]>
>>>
>>>  Hi,
>>>
>>>>
>>>> I tried following URL to set currency but it is not working
>>>>
>>>>
>>>>
>>>> http://demo.hotwaxmedia.com/ecommerce/control/setSessionCurrencyUom?currencyUom=INR
>>>>
>>>> Regards,
>>>> Abhishake
>>>>
>>>> On Sun, Oct 5, 2008 at 10:36 PM, Abhishake Agarwal <
>>>> [hidden email]> wrote:
>>>>
>>>>  Hi,
>>>>
>>>>>
>>>>> I want to know whether it is possible to set currency dynamically.
>>>>>
>>>>> Suppose on ecommerce application, I have a currency options and if user
>>>>> select any of the type of currency, application should set that
>>>>> currency
>>>>> for
>>>>> that user.
>>>>>
>>>>> Regards,
>>>>> Abhishake
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>