Jump to content

Account creation


cedric le roy

Recommended Posts

Hi,

 

I would like to set a user in a group (native groups) (personnal customer of professional customer) at the account creation if he had set his SIRET or/and Company Name

 

I found creation action in AuthController --> processSubmitAccount

 

but i didn't find anywhere about saving Siret and company name in database?

 

Could you tell me where those informations are set? or how to manage this group affectation by building a plugin or extending core AuthController?

 

Thanks in advance

 

Cédric LE ROY

Link to comment
Share on other sites

Hi Cedric,

 

I would try to modify classes/Customer.php, Add() function:

	public function add($autodate = true, $null_values = true)
	{
		$this->id_shop = ($this->id_shop) ? $this->id_shop : Context::getContext()->shop->id;
		$this->id_shop_group = ($this->id_shop_group) ? $this->id_shop_group : Context::getContext()->shop->id_shop_group;
		$this->id_lang = ($this->id_lang) ? $this->id_lang : Context::getContext()->language->id;
		$this->birthday = (empty($this->years) ? $this->birthday : (int)$this->years.'-'.(int)$this->months.'-'.(int)$this->days);
		$this->secure_key = md5(uniqid(rand(), true));
		$this->last_passwd_gen = date('Y-m-d H:i:s', strtotime('-'.Configuration::get('PS_PASSWD_TIME_FRONT').'minutes'));
		
		if ($this->newsletter && !Validate::isDate($this->newsletter_date_add))
			$this->newsletter_date_add = date('Y-m-d H:i:s');
			
		if ($this->id_default_group == Configuration::get('PS_CUSTOMER_GROUP'))
			if ($this->is_guest)
				$this->id_default_group = (int)Configuration::get('PS_GUEST_GROUP');
			else
				$this->id_default_group = (int)Configuration::get('PS_CUSTOMER_GROUP');

/* MAYBE HERE CHECK HERE: if ($this->siret has a value) 
   then: $this->id_default_group = _MY_NEW_CUSTOMER_GROUP;

		/* Can't create a guest customer, if this feature is disabled */
		if ($this->is_guest && !Configuration::get('PS_GUEST_CHECKOUT_ENABLED'))
			return false;
	 	$success = parent::add($autodate, $null_values);
		$this->updateGroup($this->groupBox);
		return $success;
	}

Hope this helps,

pascal

Edited by PascalVG (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...