Jump to content

Users default currency


Recommended Posts

Once the user set's their currency and as long as their cookie is good it will remember.

 

You can't set a user's currency from the back office.

 

Non-logged visitors without a cookie (first time or after cookie expires) will get shop default currency.

 

You can set currency by country, then you can use the native Geo Location to detect their country (for non-logged).

Link to comment
Share on other sites

Ok, little change in core file classes\controller\FrontController.php

 

put this code before

$currency = Tools::setCurrency($this->context->cookie);

(around line 150)

//if is customer logged in, we will change his currency.
if($this->context->customer->logged && !$cookie->is_curr_changed){
	 $_POST['SubmitCurrency'] = 1;
	 $_POST['id_currency'] =  Db::getInstance()->getValue("SELECT currency FROM "._DB_PREFIX_."customer WHERE id_customer=".$this->context->customer->id.";", $use_cache = 0);
	 $cookie->is_curr_changed = 1;
}

 

need update db too - we are importing this value, so you must change customer value manually by the phpMyAdmin

ALTER TABLE YOUR_PREFIX_customer ADD COLUMN currency int(2) DEFAULT 1

Edited by haunter (see edit history)
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...