Looking for documentation? Take a look on our wiki

Main Menu

Setting shoppergroups for country

Started by Kashif Nawaid, April 23, 2014, 22:23:30 PM

Previous topic - Next topic

Kashif Nawaid

Hello there,

I want to change the shoppergroup based on a particular country.

I am using a plugin to find the country from where user has logged in and display the currency accordingly.

eg., if i am surfing from INDIA then country code is IN, then set the shoppergroup = '3' (don't know how to write in PHP)


for($i = 1; $i < 6; $i++){
if($this->params->get("currency".$i) && $this->params->get("country".$i)){
$countries_list = str_replace(";","",$this->params->get("country".$i));
$countries_list = explode("\r\n",$countries_list);
$countries_list_ = array();
foreach($countries_list as $countries_)
$countries_list_[] = strtoupper($countries_);
$countries_list = $countries_list_;
if(in_array($detected_country_code, $countries_list)){
$currency_code = $this->getCurrencyCode($this->params->get("currency".$i));
$this->mainframe->setUserState( "virtuemart_currency_id", $currency_code );

$rule = TRUE;
if($this->params->get("visitorip")) {

$this->MessageOutput(  'Currency set to: '.$this->getCurrencyName($currency_code));
$this->MessageOutput(  "--------------------" );
$this->MessageOutput(  'Currency code: '.$currency_code);
$this->MessageOutput(  "--------------------" );



if(!$rule) {
$this->mainframe->setUserState( "virtuemart_currency_id", $this->vendor_default_currency );
UnitechWorld Services