- Posts: 16
- Thank you received: 0
How to access Currency variable in user cookie?
13 years 4 months ago - 13 years 4 months ago #106563
by mixsemi
How to access Currency variable in user cookie? was created by mixsemi
Hi,
I am trying to use Jumi to write some custom code and need to access the Currency ID on the customer's cookie.
Basically, I want to display a price list of a bunch of my products on one single page. Right now it is in USD, but I want to make it so that when the customer changes the currency to say EUR, all the prices on the price list change to EUR automatically.
I know how to write PHP code to access mysql data, but I don't know how to access the Currency ID number on the cookie.
Can someone please kindly let me know how I can access the cookie data? Assume that I am starting on a blank PHP script with nothing initialized (a blank Jumi page).
Thanks,
Robin
I am trying to use Jumi to write some custom code and need to access the Currency ID on the customer's cookie.
Basically, I want to display a price list of a bunch of my products on one single page. Right now it is in USD, but I want to make it so that when the customer changes the currency to say EUR, all the prices on the price list change to EUR automatically.
I know how to write PHP code to access mysql data, but I don't know how to access the Currency ID number on the cookie.
Can someone please kindly let me know how I can access the cookie data? Assume that I am starting on a blank PHP script with nothing initialized (a blank Jumi page).
Thanks,
Robin
Last edit: 13 years 4 months ago by mixsemi.
Please Log in or Create an account to join the conversation.
13 years 4 months ago #106586
by nicolas
Replied by nicolas on topic How to access Currency variable in user cookie?
Hi,
The currency id is not stored in user cookies but in the user session.
If HikaShop is loaded, you can simply call the function hikashop_getCurrency() and that will give you back the current currency id.
Otherwise, you can use:
$app = JFactory::getApplication();
$main_currency = 2;
$currency_id = (int)$app->getUserState( 'com_hikashop.currency_id', $main_currency );
Note that there is already a currency switcher module installed automatically along with HikaShop.
The currency id is not stored in user cookies but in the user session.
If HikaShop is loaded, you can simply call the function hikashop_getCurrency() and that will give you back the current currency id.
Otherwise, you can use:
$app = JFactory::getApplication();
$main_currency = 2;
$currency_id = (int)$app->getUserState( 'com_hikashop.currency_id', $main_currency );
Note that there is already a currency switcher module installed automatically along with HikaShop.
The following user(s) said Thank You: mixsemi
Please Log in or Create an account to join the conversation.
13 years 4 months ago #106656
by mixsemi
Replied by mixsemi on topic How to access Currency variable in user cookie?
This worked! T H A N K Y O U !!!
Please Log in or Create an account to join the conversation.
Time to create page: 0.166 seconds