How to access Currency variable in user cookie?

  • Posts: 16
  • Thank you received: 0
10 years 11 months ago #106563

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

Last edit: 10 years 11 months ago by mixsemi.

Please Log in or Create an account to join the conversation.

  • Posts: 81675
  • Thank you received: 13096
  • MODERATOR
10 years 11 months ago #106586

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 following user(s) said Thank You: mixsemi

Please Log in or Create an account to join the conversation.

  • Posts: 16
  • Thank you received: 0
10 years 11 months ago #106656

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.059 seconds
Powered by Kunena Forum