• Welcome to KonaKart Community Forum. Please login or sign up.
 

Change currency using java API

Started by tqumhieh, February 13, 2013, 07:25:34 am

Previous topic - Next topic

tqumhieh

Hi Guys,

How can I programmatically change the currency view in my front store? I'm building a custom portal and wishes to have a drop down menu where users can select the currency and all prices will be changed according to this selection.
I'm using the latest  6.5 version, and what I want to know:
1) how to change currency using API.
2) once currency changed, will prices be reflected automatically or is this a manual effort I have to maintain?

trevor

The KK store-front already has a drop down menu to select currency.

If you want to know how it works you should look at the code in the struts action class. The form calls SetLocale.action which runs the code in SetLocaleAction.java .

The conversion rate is defined in the value of the currency object. The default currency has a value of 1 and any other defined currency has a value which is used as a multiplier to apply the conversion.

tqumhieh

Thanks for the reply, but does this mean once I set the new currency and requery products, their prices will be reflected automatically to match the new currency? Or do I need to loop over the product and multiply with the currency factor

trevor


tqumhieh

I think you mean SelectCurrencyAction.java and not SetLocaleAction.java Anyhow, it seems im having issues initializing KKAppEng, im trying to do so from a JSF managed bean, and im not using struts in my application, will that cause any issue?

trevor

QuoteI think you mean SelectCurrencyAction.java and not SetLocaleAction.java

Yes, sorry, slip on my part.

Quoteit seems im having issues initializing KKAppEng, im trying to do so from a JSF managed bean, and im not using struts in my application, will that cause any issue?

You don't need to use Struts. In this case it may be easier to directly call the server engine APIs and not use KKAppEng. Here's an example of a JSF application using KK : https://raceforlife.cancerresearchuk.org/rfl/forms/shop/shop.jsf . If you don't use KKAppEng you will have to perform the currency multiplication on the array of products received from the KK server engine.

tqumhieh

Thanks trevor, then this lead us to the original question once again, how to change the default currency utilizing the KKEngine server APIs? as all examples simply use the KKAppEngine

trevor

You save the customers selection in the session or a cookie or a customer tag (EE only) and do the multiplication yourself before displaying.