News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

VM3.0.18 - Saving edit address removes users groups

Started by xtech86, January 12, 2017, 15:43:56 PM

Previous topic - Next topic

xtech86

Hello,

In VM 3.0.18 when you are logged in as an  super user for example and edit the billing address in the frontend VM runs the model file:
/administrator/components/com_virtuemart/models/user.php

And in turn on line 160 you set the shopper groups to a plain array which then causes VM to set the default shopper group see:

if(empty($this->_data->shopper_groups)) $this->_data->shopper_groups = array();


VM needs to be doing a check that this is not the billing or ship to address layout before touching the users shopper groups. As our user then has to login and set the shopper group for the next order they place.

Many thanks
Tony

Milbo

I think the problem is not in user load, it is in the store function, line 558


if(vmAccess::manager('user.edit')){

$shoppergroupmodel = VmModel::getModel('ShopperGroup');
if(empty($this->_defaultShopperGroup)){
$this->_defaultShopperGroup = $shoppergroupmodel->getDefault(0);
}

if(empty($data['virtuemart_shoppergroup_id']) or $data['virtuemart_shoppergroup_id']==$this->_defaultShopperGroup->virtuemart_shoppergroup_id){
$data['virtuemart_shoppergroup_id'] = array();
}

//We can't do that here, because it deletes the shoppergroup of users with "user.edit" permissions when they checkout
/*if(!isset($data['virtuemart_shoppergroup_id'])){
$data['virtuemart_shoppergroup_id'] = array();
}*/
$shoppergroupData = array('virtuemart_user_id'=>$this->_id,'virtuemart_shoppergroup_id'=>$data['virtuemart_shoppergroup_id']);
$user_shoppergroups_table = $this->getTable('vmuser_shoppergroups');
$res = $user_shoppergroups_table -> bindChecknStore($shoppergroupData);
if(!$res){
vmError('Set shoppergroup error');
$noError = false;
}

}


The reason is that a manager usually sents this data automatically. So we just need to add here that the data is loaded before like already done for the user_is_vendor
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/