Jump to content

Different Regitration Group by condition


Recommended Posts

Prestashop 1.6.1.0

 

I'm trying to give different groups to newly registered users by conditions.

 

if the company field is filled the group will bee companys, if not filled in the group will bee default group.

 

 

In the ps_configuration table i added a field 'PS_COMPANY_GROUP' field copied by 'PS_CUSTOMER_GORUP', changing the group value to company group value.

 

then in classes/customer.php i added

/** @var int Default group ID */
	public $id_company_group;

and:

'id_company_group' => 			array('type' => self::TYPE_INT, 'copy_post' => false),

under 

'id_default_group' => 			array('type' => self::TYPE_INT, 'copy_post' => false),

now in Authcontroller.php:

 

i had replaced:

$customer->addGroups(array((int)Configuration::get('PS_CUSTOMER_GROUP')));

with:

if (Tools::getValue('company') == '') {
	    
					$customer->addGroups(array((int)Configuration::get('PS_CUSTOMER_GROUP')));
                         } else {
	      
					$customer->addGroups(array((int)Configuration::get('PS_COMPANY_GROUP')));
                         }

buti it doesn't work

 

i thik i miss something in customer group

 

 

any help will be appreciated

:)

Edited by fabyox (see edit history)
Link to comment
Share on other sites

Prestashop 1.6.1.0

 

i Solved by myself if someone is interested

 

i did like this:

 

 

no new table in db

 

i changed in classes/customer.php before "public function add($autodate = true, $null_values = true)"

$this->id_default_group = (int)Configuration::get('PS_CUSTOMER_GROUP');

to

$this->id_default_group = 4;

in  "public function add($autodate = true, $null_values = true)" i changed:

if $this->id_default_group = (int)Configuration::get('PS_CUSTOMER_GROUP');
			if ($this->is_guest)
				$this->id_default_group = (int)Configuration::get('PS_GUEST_GROUP');
			else
				if $this->id_default_group = (int)Configuration::get('PS_CUSTOMER_GROUP');

to:

if (!Tools::getValue('company')==true)
		if ($this->id_default_group == 4)
			if ($this->is_guest)
				$this->id_default_group = (int)Configuration::get('PS_GUEST_GROUP');
			else
				$this->id_default_group = 3;

where 4 is ID of my company group and 3 is the customer ID group, is someone will fill B2B (company) fields will be putted in company group, now i have to deactivate, redirect, and send different mail to company's customers, for now my topic i solved.

 

maybe is not perfect way to do that, buti it's working good for me  :)

 

hope this help somebody

Edited by fabyox (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...