Jump to content

How can I change User Language and Currency?


Recommended Posts

I'm building a mobile app for prestashop using RestAPI.

There is a feature that I want to do but I can't quite do. I want to choose the language and currency from the settings page and proceed that way.


I somehow managed to do this. When I check with postman, I see that the language and currency I want works.

But when I try to do this using Flutter, when the user logs in, English and dollar are automatically selected. I am using shared preferences to store cookies.

 

            $idCurrency = Db::getInstance()->getValue('SELECT `id_currency` FROM `'._DB_PREFIX_.'currency` WHERE `iso_code`="'.$currencyIsoCode.'" AND `active`=1 AND `deleted`=0');
            $this->context->cookie->id_currency = $idCurrency;
            Tools::setCurrency($this->context->cookie);
            $idLanguage = Db::getInstance()->getValue('SELECT `id_lang` FROM `'._DB_PREFIX_.'lang` WHERE active = 1 AND iso_code="'.$langIsoCode.'"');
            $this->context->cookie->id_lang = $idLanguage;
            Tools::setCookieLanguage($this->context->cookie);

here the postman result:https://prnt.sc/1ajoa8m

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...