Jump to content

separate registration forms for different customer groups?


Recommended Posts

My client wants to have two different groups of customers on his site. One of the groups gets to see more product and has reduced pricing (we'll call these customers "designers"). It's easy to create a customer group called "designers" and manually assign people to it. But my client wants to be able to have the designers register through a different form than the rest of the customers use, with some different fields, so they'll automatically be placed into the designer group after submitting this form.

How can I create multiple registration forms that assign customers into different groups?

The next thing is even trickier: Can you set up a way to catch the new designers registering and have an admin approve them before their accounts are fully registered and they can log in?

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
  • 1 year later...
  • 2 months later...

Okay, I have manage to get to one stage.. and the problem now is this:

 

I have created copies of authentication files.. and just renamed them to authentication2, my-account2 etc..

 

Why do I get this error:

 

Warning: require_once(/home4/xxcomhr/public_html/akm-novo/config/../classes/AuthController2.php) [function.require-once]: failed to open stream: No such file or directory in /home4/xxcomhr/public_html/akm-novo/config/autoload.php on line 41

 

Fatal error: require_once() [function.require]: Failed opening required '/home4/xxcomhr/public_html/akm-novo/config/../classes/AuthController2.php' (include_path='.:/usr/lib64/php:/usr/lib/php:/usr/share/pear') in /home4/xxcomhr/public_html/akm-novo/config/autoload.php on line 41

 

The path is working fine with original file.. so I didnt change anything except renamed the files (the idea is to have different .tpl files and to have wholesaler registration)

 

Can someone please help me with wrong path issue.

Thanks.

Link to comment
Share on other sites

  • 1 month later...
  • 1 year later...
  • 3 months later...

Here is the way how I did it:

 

-My needs: I have 2 different groups, default customer group and professional customer group.

In default group ARE NOT requiered the fields company and identification number, but in professional group these fields are requiered.

Furthermore, when somebody register an account as professional it must be manually activated and when register finish it should redirect to a CMS page showing a custom message "account must be revised by admin...."

 

First of all, my ps version is 1.4.5.1. I am planning to move to 1.4.10 so I hope it will work.

BEFORE ANY CHANGE, MAKE A BACKUP OF YOUR STORE. IT WORKED FOR ME BUT IT IS NOT GUARANTEED IT WILL WORK FOR YOU.

 

-Duplicate in root folder the file "authentication.php" to "authentication2.php". Regular customers will register in www.yourshop.com/authentication.php and professional customers will register in www.yourshop.com/authentication2.php

 

-In the new created file "authentication2.php" in line 29 change line

ControllerFactory::getController('AuthController')->run();

by

ControllerFactory::getController('AuthController2')->run();

 

-Duplicate controllers/AuthController.php to controllers/AuthController2.php

 

-In controllers/Authcontroller2.php change:

in line 28~:

class AuthControllerCore extends FrontController

by

class AuthController2Core extends FrontController

 

in line 31~ change:

public $php_self = 'authentication.php';

by

public $php_self = 'authentication2.php';

 

in line 395~ change:

self::$smarty->display(_PS_THEME_DIR_.'authentication.tpl');

by

self::$smarty->display(_PS_THEME_DIR_.'authentication2.tpl');

 

Next code is optional, as I said, in my shop default customer doesnt need identification number field, to do it I added this code:

if (!Validate::isDniLite(Tools::getValue('dni')))

instead

if (Country::isNeedDniByCountryId($address->id_country) AND (!Tools::getValue('dni') OR !Validate::isDniLite(Tools::getValue('dni'))))

but now I want to revert that behavior. Then I will add in "AuthController2.php" the original code

if (Country::isNeedDniByCountryId($address->id_country) AND (!Tools::getValue('dni') OR !Validate::isDniLite(Tools::getValue('dni'))))

instead modified code

if (!Validate::isDniLite(Tools::getValue('dni')))

 

-To keep authentication language translation working you should duplicate all the lines which start by "$_LANG['authentication_..." in "themes/yourtheme/lang/yourlang.php", the duplicated lines should start by "$_LANG['authentication2_"

 

-Duplicate themes/yourtheme/authentication.tpl to authentication2.tpl

 

-In themes/yourtheme/authentication2.tpl change any reference to "authentication.php" by "authentication2.php"

 

-This is an optional step, as I said in my default group is not requiered the "company" field, so to make it requiered in new professional group I will duplicate in classes/Adress.php the line 99~, original line:

protected $fieldsRequired = array('id_country', 'alias', 'lastname', 'firstname', 'address1', 'city');

duplicated and modified line

protected $fieldsRequired2 = array('id_country', 'alias', 'lastname', 'firstname', 'address1', 'city','company');

 

-In class/ObejectModel.php duplicate the functions "validateControler" and "validateController". Duplicate from line 467~ to 513~, this:

public function validateControler($htmlentities = true)
{
 return $this->validateController($htmlentities);
}
public function validateController($htmlentities = true)
{
 $errors = array();
 /* Checking for required fields */
 $fieldsRequired = array_merge($this->fieldsRequired, (isset(self::$fieldsRequiredDatabase[get_class($this)]) ? self::$fieldsRequiredDatabase[get_class($this)] : array()));
 foreach ($fieldsRequired AS $field)
 if (($value = Tools::getValue($field, $this->{$field})) == false AND (string)$value != '0')
  if (!$this->id OR $field != 'passwd')
$errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.');

 /* Checking for maximum fields sizes */
 foreach ($this->fieldsSize AS $field => $maxLength)
  if (($value = Tools::getValue($field, $this->{$field})) AND Tools::strlen($value) > $maxLength)
$errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is too long.').' ('.Tools::displayError('Maximum length:').' '.$maxLength.')';
 /* Checking for fields validity */
 foreach ($this->fieldsValidate AS $field => $function)
 {
  // Hack for postcode required for country which does not have postcodes
  if ($value = Tools::getValue($field, $this->{$field}) OR ($field == 'postcode' AND $value == '0'))
  {
if (!Validate::$function($value))
 $errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is invalid.');
else
{
 if ($field == 'passwd')
 {
  if ($value = Tools::getValue($field))
   $this->{$field} = Tools::encrypt($value);
 }
 else
  $this->{$field} = $value;
}
  }
 }
 return $errors;
}

 

in duplicated lines, do this changes:

public function validateControler($htmlentities = true)

by

public function validateControler2($htmlentities = true)

 

return $this->validateController($htmlentities);

by

return $this->validateController2($htmlentities);

 

public function validateController($htmlentities = true)

by

public function validateController2($htmlentities = true)

 

$fieldsRequired = array_merge($this->fieldsRequired, (isset(self::$fieldsRequiredDatabase[get_class($this)]) ? self::$fieldsRequiredDatabase[get_class($this)] : array()));

by

$fieldsRequired2 = array_merge($this->fieldsRequired2, (isset(self::$fieldsRequiredDatabase[get_class($this)]) ? self::$fieldsRequiredDatabase[get_class($this)] : array()));

 

foreach ($fieldsRequired AS $field)

by

foreach ($fieldsRequired2 AS $field)

 

-In controllers/AuthController2.php, change

$this->errors = array_unique(array_merge($this->errors, $address->validateControler()));

by

$this->errors = array_unique(array_merge($this->errors, $address->validateControler2()));

 

-To make new user inactive by default, change in "controllers/AuthController2.php":

in line 152~

$customer->active = 1;

by

$customer->active = 0;

 

in line 178~:

self::$cookie->logged = 1;

by

self::$cookie->logged = 0;

 

-To change the redirect behavior just when user finishes registration change in "controllers/AuthController2.php"

in line 205~:

Tools::redirect('my-account.php');

by

Tools::redirect('cms.php?id_cms=14');

instead 'cms.php?id_cms=14' it could be your seo friendly url... 'content/customcmspage' or any url starting from www.yourshop.com

 

Admin must activate new user and put in desired group

 

 

Thanks NikPraskaton for help community NOT sharing your solution :wacko:

Edited by lain (see edit history)
  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

Related to the topic I managed to:

-If user belongs to certain group, it shows their price and regular user price stroked. In product page, homefeatured and category.

-I can set different amount in "Remaining amount to free shipping" depending of group. In blockcart and order summary.

-Each group can see different images in banners

Link to comment
Share on other sites

Here is the way how I did it:

 

-My needs: I have 2 different groups, default customer group and professional customer group.

In default group ARE NOT requiered the fields company and identification number, but in professional group these fields are requiered.

Furthermore, when somebody register an account as professional it must be manually activated and when register finish it should redirect to a CMS page showing a custom message "account must be revised by admin...."

 

First of all, my ps version is 1.4.5.1. I am planning to move to 1.4.10 so I hope it will work.

BEFORE ANY CHANGE, MAKE A BACKUP OF YOUR STORE. IT WORKED FOR ME BUT IT IS NOT GUARANTEED IT WILL WORK FOR YOU.

 

-Duplicate in root folder the file "authentication.php" to "authentication2.php". Regular customers will register in www.yourshop.com/authentication.php and professional customers will register in www.yourshop.com/authentication2.php

 

-In the new created file "authentication2.php" in line 29 change line

ControllerFactory::getController('AuthController')->run();

by

ControllerFactory::getController('AuthController2')->run();

 

-Duplicate controllers/AuthController.php to controllers/AuthController2.php

 

-In controllers/Authcontroller2.php change:

in line 28~:

class AuthControllerCore extends FrontController

by

class AuthController2Core extends FrontController

 

in line 31~ change:

public $php_self = 'authentication.php';

by

public $php_self = 'authentication2.php';

 

in line 395~ change:

self::$smarty->display(_PS_THEME_DIR_.'authentication.tpl');

by

self::$smarty->display(_PS_THEME_DIR_.'authentication2.tpl');

 

Next code is optional, as I said, in my shop default customer doesnt need identification number field, to do it I added this code:

if (!Validate::isDniLite(Tools::getValue('dni')))

instead

if (Country::isNeedDniByCountryId($address->id_country) AND (!Tools::getValue('dni') OR !Validate::isDniLite(Tools::getValue('dni'))))

but now I want to revert that behavior. Then I will add in "AuthController2.php" the original code

if (Country::isNeedDniByCountryId($address->id_country) AND (!Tools::getValue('dni') OR !Validate::isDniLite(Tools::getValue('dni'))))

instead modified code

if (!Validate::isDniLite(Tools::getValue('dni')))

 

-To keep authentication language translation working you should duplicate all the lines which start by "$_LANG['authentication_..." in "themes/yourtheme/lang/yourlang.php", the duplicated lines should start by "$_LANG['authentication2_"

 

-Duplicate themes/yourtheme/authentication.tpl to authentication2.tpl

 

-In themes/yourtheme/authentication2.tpl change any reference to "authentication.php" by "authentication2.php"

 

-This is an optional step, as I said in my default group is not requiered the "company" field, so to make it requiered in new professional group I will duplicate in classes/Adress.php the line 99~, original line:

protected $fieldsRequired = array('id_country', 'alias', 'lastname', 'firstname', 'address1', 'city');

duplicated and modified line

protected $fieldsRequired2 = array('id_country', 'alias', 'lastname', 'firstname', 'address1', 'city','company');

 

-In class/ObejectModel.php duplicate the functions "validateControler" and "validateController". Duplicate from line 467~ to 513~, this:

public function validateControler($htmlentities = true)
{
 return $this->validateController($htmlentities);
}
public function validateController($htmlentities = true)
{
 $errors = array();
 /* Checking for required fields */
 $fieldsRequired = array_merge($this->fieldsRequired, (isset(self::$fieldsRequiredDatabase[get_class($this)]) ? self::$fieldsRequiredDatabase[get_class($this)] : array()));
 foreach ($fieldsRequired AS $field)
 if (($value = Tools::getValue($field, $this->{$field})) == false AND (string)$value != '0')
  if (!$this->id OR $field != 'passwd')
$errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.');

 /* Checking for maximum fields sizes */
 foreach ($this->fieldsSize AS $field => $maxLength)
  if (($value = Tools::getValue($field, $this->{$field})) AND Tools::strlen($value) > $maxLength)
$errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is too long.').' ('.Tools::displayError('Maximum length:').' '.$maxLength.')';
 /* Checking for fields validity */
 foreach ($this->fieldsValidate AS $field => $function)
 {
  // Hack for postcode required for country which does not have postcodes
  if ($value = Tools::getValue($field, $this->{$field}) OR ($field == 'postcode' AND $value == '0'))
  {
if (!Validate::$function($value))
 $errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is invalid.');
else
{
 if ($field == 'passwd')
 {
  if ($value = Tools::getValue($field))
   $this->{$field} = Tools::encrypt($value);
 }
 else
  $this->{$field} = $value;
}
  }
 }
 return $errors;
}

 

in duplicated lines, do this changes:

public function validateControler($htmlentities = true)

by

public function validateControler2($htmlentities = true)

 

return $this->validateController($htmlentities);

by

return $this->validateController2($htmlentities);

 

public function validateController($htmlentities = true)

by

public function validateController2($htmlentities = true)

 

$fieldsRequired = array_merge($this->fieldsRequired, (isset(self::$fieldsRequiredDatabase[get_class($this)]) ? self::$fieldsRequiredDatabase[get_class($this)] : array()));

by

$fieldsRequired2 = array_merge($this->fieldsRequired2, (isset(self::$fieldsRequiredDatabase[get_class($this)]) ? self::$fieldsRequiredDatabase[get_class($this)] : array()));

 

foreach ($fieldsRequired AS $field)

by

foreach ($fieldsRequired2 AS $field)

 

-In controllers/AuthController2.php, change

$this->errors = array_unique(array_merge($this->errors, $address->validateControler()));

by

$this->errors = array_unique(array_merge($this->errors, $address->validateControler2()));

 

-To make new user inactive by default, change in "controllers/AuthController2.php":

in line 152~

$customer->active = 1;

by

$customer->active = 0;

 

in line 178~:

self::$cookie->logged = 1;

by

self::$cookie->logged = 0;

 

-To change the redirect behavior just when user finishes registration change in "controllers/AuthController2.php"

in line 205~:

Tools::redirect('my-account.php');

by

Tools::redirect('cms.php?id_cms=14');

instead 'cms.php?id_cms=14' it could be your seo friendly url... 'content/customcmspage' or any url starting from www.yourshop.com

 

Admin must activate new user and put in desired group

 

 

Thanks NikPraskaton for help community NOT sharing your solution :wacko:

 

Hellow Lain

 

Thank you very much for sharing the knowledge , and special thanks to NikPraskaton too LOL

 

I need some help please, im stucked in the first step, when i open "authentication2.php" i got this : bug.png

Thank you

Best Regarts

CLineTech

Link to comment
Share on other sites

Well, it seems that files are bit different from 1.4.5.1(my version) to 1.5.x (your version)

I have not any store running on 1.5.x so I cant test it but it looks that changing

Tools::redirect('index.php?controller=authentication'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');

to

Tools::redirect('index.php?controller=authentication2'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');

 

and then in "AuthController2.php" change the AuthControllerCore to AuthControllerCore2 and:

public $php_self = 'authentication';

to

public $php_self = 'authentication2';

etc... etc...

 

But, as I said, its not tested on 1.5.x.

Edited by lain (see edit history)
  • Like 1
Link to comment
Share on other sites

Well, it seems that files are bit different from 1.4.5.1(my version) to 1.5.x (your version)

I have not any store running on 1.5.x so I cant test it but it looks that changing

Tools::redirect('index.php?controller=authentication'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');

to

Tools::redirect('index.php?controller=authentication2'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');

 

and then in "AuthController2.php" change the AuthControllerCore to AuthControllerCore2 and:

public $php_self = 'authentication';

to

public $php_self = 'authentication2';

etc... etc...

 

But, as I said, its not tested on 1.5.x.

 

Thank you very much, i will test and give feedback ,

Link to comment
Share on other sites

My client wants to have two different groups of customers on his site. One of the groups gets to see more product and has reduced pricing (we'll call these customers "designers"). It's easy to create a customer group called "designers" and manually assign people to it. But my client wants to be able to have the designers register through a different form than the rest of the customers use, with some different fields, so they'll automatically be placed into the designer group after submitting this form.

 

How can I create multiple registration forms that assign customers into different groups?

 

The next thing is even trickier: Can you set up a way to catch the new designers registering and have an admin approve them before their accounts are fully registered and they can log in?

 

Hi I can help you regarding your problem,

 

And i have already make some core module for this type solution, like multiple user group, multiple reg form, also need admin approval for complete the reg.

 

Contact me here:- https://www.odesk.com/users/~01d2c05933fd4dec1a

Link to comment
Share on other sites

  • 1 month later...
Could you let us know how you got on? Thanks

 

I tested using prestashop 1.5.4.1, and didnt work for me, the problem is that when I try to access www.mysite/index.php?controller=authentication2&back=my-account, i get error 404 the same with www.mysite.com/authentication2.php, can somebody give me some input. Thanks.

Link to comment
Share on other sites

  • 9 months later...
  • 1 month later...
  • 3 months later...
  • 1 month later...
  • 3 months later...
  • 1 month later...

separate registration forms for different customer groups in prestashop 1.6

 

i am creating different groups where if user will registered from the student group then he got 10% discount so if there is any free  module or any help then please tell ....

and i also need help that students group registration fields are to be changed

 

thanks in advance

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

  • 1 month later...
  • 3 months later...

Ok, I could not find any extensions that do this for prestashop 1.6, so ended up building the functionality myself.  Please backup any files before attempting to making any changes detailed in this post.

 

My needs:  the functionality to create a separate registration page for a wholesale account.  In processing the registration, the account is initially inactive and a notification email is sent to the admin to prompt him/her to approve.

 

Here is the full code: wholesale_registration.zip

Edit: Above link does not seem to work anymore, here is dropbox link: https://www.dropbox.com/s/hu6nc5yy91mupd7/wholesale_registration.zip?dl=0

 

 

1.  Added the override file:

/override/controllers/front/AuthController.php

THIS IS NOT THE FULL CODE SO DO NOT COPY AND PASTE

<?php

class AuthController extends AuthControllerCore
{

	public $wholesale_customer_group = 4;
	
//
//
// more code here
//
//
	
	public function processSubmitAccountWholesale() {

		$this->processSubmitAccountWholesaleCreateAccount();
		
		if(empty($this->errors)) {
			$customer = $this->context->customer;

			// add customer to wholesale group
			$customer->cleanGroups(); // delete all customer groups
			$customer->addGroups(array((int)$this->wholesale_customer_group));
			
			// disable customer, needs approval
			if($customer->active==1) $customer->toggleStatus();
			
			// send email to admin for approval
			Mail::Send(
				$this->context->language->id,
				'wholesale_registration',
				Mail::l('Wholesale Registration'),
				array(
					'{firstname}' => $customer->firstname,
					'{lastname}' => $customer->lastname,
					'{email}' => $customer->email,
					'{passwd}' => Tools::getValue('passwd')),
				Configuration::get('PS_SHOP_EMAIL'),
				Configuration::get('PS_SHOP_NAME')
			);
			
			
			// now log the customer out
			$customer->logout();
			
			
			//
			// finishing touches from processSubmitAccount()
			//
			if (!$customer->is_guest)
				if (!$this->sendConfirmationMail($customer))
					$this->errors[] = Tools::displayError('The email cannot be sent.');

			
			if ($this->ajax)
			{
				$return = array(
					'hasError' => !empty($this->errors),
					'errors' => $this->errors,
					'isSaved' => true,
					'id_customer' => (int)$this->context->cookie->id_customer,
					'id_address_delivery' => $this->context->cart->id_address_delivery,
					'id_address_invoice' => $this->context->cart->id_address_invoice,
					'token' => Tools::getToken(false)
				);
				die(Tools::jsonEncode($return));
			}

			Tools::redirect('index.php?controller=authentication&layout=wholesale_confirm');
		}
	}
	
	
//
//
// more code here
//
//

}

If you need to edit this file, the above are most likely what you need to edit.  $wholesale_customer_group is the id of the wholesale customer group.  Function processSubmitAccountWholesale adds the customer to the wholesale group, inactivates the account, logs out the user, and sends the notification email to the admin.

 

One other note, if you are are adding this file for the first time, you will need to delete or rename the file /cache/class_index.php for the override to take effect.

 

 

2.  Add the registration template file

/themes/[YOUR_THEME]/authentication_wholesale.tpl

 

This file is just a copy of /themes/[YOUR_THEME]/authentication.tpl, with 2 changes

 

First I changed:

<form action="{$link->getPageLink('authentication', true)|escape:'html':'UTF-8'}" method="post" id="account-creation_form" class="std box">

to this

<form action="{$link->getPageLink('authentication', true, NULL, 'layout=wholesale')|escape:'html':'UTF-8'}" method="post" id="account-creation_form" class="std box">

And changed this

<button type="submit" name="submitAccount" id="submitAccount" class="btn btn-default button button-medium">

to this:

<button type="submit" name="SubmitAccountWholesale" id="SubmitAccountWholesale" class="btn btn-default button button-medium">

3. Add the registration confirmation template

/themes/[YOUR_THEME]/authentication_wholesale_confirm.php

This is just the confirmation page that is shown after registering on the wholesale confirmation account

 

 

4. Add the mail templates

/themes/[YOUR_THEME]/mails/[iSO]/wholesale_registration.html

/themes/[YOUR_THEME]/mails/[iSO]/wholesale_registration.txt

This is the email notification sent to the admin

 

 

That is it.  If everything is done correctly, you will be able to access the separate registration page here:

[YOUR_WEBSITE_ADDRESS]/index.php?controller=authentication&layout=wholesale

 

Here is the full code: wholesale_registration.zip

Edit: Above link does not seem to work anymore, here is dropbox link: https://www.dropbox.com/s/hu6nc5yy91mupd7/wholesale_registration.zip?dl=0

 

 

Edited by seyi (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Hi,

This not work in v.1.6.1.1 ?

 

Have tried it and the result is the following:

-Admin Receives no mail about registration
- Wholesale customer is registered in the standard customer group (ID1) and are automatically logged on customer backoffice.

From what I understand of these modified codes, the following happen:

- Customer group "wholesale" should be created (group ID4)
- When a wholesale customer signs up, this customer will automatically be added to wholesale group  ID4, but inactive to admin has approved this customer. Admin will receive an email about this.

Have I misunderstood something here?
Link to comment
Share on other sites

Hello,

 

In your authentication_wholesale.tpl, did you update the form action and the submit button?

For the override AuthController.php, you got that direct from the download right, not copied from the post?  And you cleared the class cache by deleting or rename the file /cache/class_index.php

Link to comment
Share on other sites

  • 2 weeks later...

Hello,

 

In your authentication_wholesale.tpl, did you update the form action and the submit button?

For the override AuthController.php, you got that direct from the download right, not copied from the post?  And you cleared the class cache by deleting or rename the file /cache/class_index.php

 
 
I downloaded the file and overwrote the original files. Deleted file /cache/class_index.php

but was still the same, registered in one group

Yes I update the form action and the submit button.

Link to comment
Share on other sites

  • 3 months later...

Ok, I could not find any extensions that do this for prestashop 1.6, so ended up building the functionality myself.  Please backup any files before attempting to making any changes detailed in this post.

 

My needs:  the functionality to create a separate registration page for a wholesale account.  In processing the registration, the account is initially inactive and a notification email is sent to the admin to prompt him/her to approve.

 

Here is the full code: attachicon.gifwholesale_registration.zip

 

 

1.  Added the override file:

/override/controllers/front/AuthController.php

THIS IS NOT THE FULL CODE SO DO NOT COPY AND PASTE

<?php

class AuthController extends AuthControllerCore
{

	public $wholesale_customer_group = 4;
	
//
//
// more code here
//
//
	
	public function processSubmitAccountWholesale() {

		$this->processSubmitAccountWholesaleCreateAccount();
		
		if(empty($this->errors)) {
			$customer = $this->context->customer;

			// add customer to wholesale group
			$customer->cleanGroups(); // delete all customer groups
			$customer->addGroups(array((int)$this->wholesale_customer_group));
			
			// disable customer, needs approval
			if($customer->active==1) $customer->toggleStatus();
			
			// send email to admin for approval
			Mail::Send(
				$this->context->language->id,
				'wholesale_registration',
				Mail::l('Wholesale Registration'),
				array(
					'{firstname}' => $customer->firstname,
					'{lastname}' => $customer->lastname,
					'{email}' => $customer->email,
					'{passwd}' => Tools::getValue('passwd')),
				Configuration::get('PS_SHOP_EMAIL'),
				Configuration::get('PS_SHOP_NAME')
			);
			
			
			// now log the customer out
			$customer->logout();
			
			
			//
			// finishing touches from processSubmitAccount()
			//
			if (!$customer->is_guest)
				if (!$this->sendConfirmationMail($customer))
					$this->errors[] = Tools::displayError('The email cannot be sent.');

			
			if ($this->ajax)
			{
				$return = array(
					'hasError' => !empty($this->errors),
					'errors' => $this->errors,
					'isSaved' => true,
					'id_customer' => (int)$this->context->cookie->id_customer,
					'id_address_delivery' => $this->context->cart->id_address_delivery,
					'id_address_invoice' => $this->context->cart->id_address_invoice,
					'token' => Tools::getToken(false)
				);
				die(Tools::jsonEncode($return));
			}

			Tools::redirect('index.php?controller=authentication&layout=wholesale_confirm');
		}
	}
	
	
//
//
// more code here
//
//

}

If you need to edit this file, the above are most likely what you need to edit.  $wholesale_customer_group is the id of the wholesale customer group.  Function processSubmitAccountWholesale adds the customer to the wholesale group, inactivates the account, logs out the user, and sends the notification email to the admin.

 

One other note, if you are are adding this file for the first time, you will need to delete or rename the file /cache/class_index.php for the override to take effect.

 

 

2.  Add the registration template file

/themes/[YOUR_THEME]/authentication_wholesale.tpl

 

This file is just a copy of /themes/[YOUR_THEME]/authentication.tpl, with 2 changes

 

First I changed:

<form action="{$link->getPageLink('authentication', true)|escape:'html':'UTF-8'}" method="post" id="account-creation_form" class="std box">

to this

<form action="{$link->getPageLink('authentication', true, NULL, 'layout=wholesale')|escape:'html':'UTF-8'}" method="post" id="account-creation_form" class="std box">

And changed this

<button type="submit" name="submitAccount" id="submitAccount" class="btn btn-default button button-medium">

to this:

<button type="submit" name="SubmitAccountWholesale" id="SubmitAccountWholesale" class="btn btn-default button button-medium">

3. Add the registration confirmation template

/themes/[YOUR_THEME]/authentication_wholesale_confirm.php

This is just the confirmation page that is shown after registering on the wholesale confirmation account

 

 

4. Add the mail templates

/themes/[YOUR_THEME]/mails/[iSO]/wholesale_registration.html

/themes/[YOUR_THEME]/mails/[iSO]/wholesale_registration.txt

This is the email notification sent to the admin

 

 

That is it.  If everything is done correctly, you will be able to access the separate registration page here:

[YOUR_WEBSITE_ADDRESS]/index.php?controller=authentication&layout=wholesale

 

Here is the full code: attachicon.gifwholesale_registration.zip

 

Does anyone have this file still? I'm getting an error trying to download the attachment and I desperately need this fix as it's exactly what I'm trying to do.

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

  • 2 weeks later...

Glad to hear it works. 

 

In your authentication_wholesale.tpl, is the form url as such?

<form action="{$link->getPageLink('authentication', true, NULL, 'layout=wholesale')|escape:'html':'UTF-8'}" method="post" id="account-creation_form" class="std box">

The "layout=wholesale" is very important

Link to comment
Share on other sites

I resolve this issue in different way - It's simpler I think....

 

result of this modification:

you will be able to add company name (and vat nr) only with customer form (not guest checkout)

and if you provide name of company you will be automaticaly added to defined group

 

first change tpls - order-opc-new-account-advanced.tpl and order-opc-new-account.tpl (the same)

for divs regarded to company add class "is_customer_param" like

                                <div class="form-group is_customer_param">
                                    <label for="company_invoice">

in database ps_configuration table add parametter PS_COMPANY_GROUP with appropriate id of group (4 or above)

 

in AuthController.php (or do overdrive) change line

                            // we add the guest customer in the default customer group
                            $customer->addGroups(array((int)Configuration::get('PS_CUSTOMER_GROUP')));

to

                            // we add the guest customer in the default customer group
                            if (empty($address->vat_number)) {
                            $customer->addGroups(array((int)Configuration::get('PS_CUSTOMER_GROUP')));
                            } else {
                            $customer->addGroups(array((int)Configuration::get('PS_COMPANY_GROUP')));
                            }

it's code of ps1.6.1.2 in other versions could be simillar

 

and enjoy :)

  • Like 1
Link to comment
Share on other sites

  • 7 months later...

Ok, I could not find any extensions that do this for prestashop 1.6, so ended up building the functionality myself.  Please backup any files before attempting to making any changes detailed in this post.

 

My needs:  the functionality to create a separate registration page for a wholesale account.  In processing the registration, the account is initially inactive and a notification email is sent to the admin to prompt him/her to approve.

 

Here is the full code: attachicon.gifwholesale_registration.zip

Edit: Above link does not seem to work anymore, here is dropbox link: https://www.dropbox.com/s/hu6nc5yy91mupd7/wholesale_registration.zip?dl=0

 

 

1.  Added the override file:

/override/controllers/front/AuthController.php

THIS IS NOT THE FULL CODE SO DO NOT COPY AND PASTE

<?php

class AuthController extends AuthControllerCore
{

	public $wholesale_customer_group = 4;
	
//
//
// more code here
//
//
	
	public function processSubmitAccountWholesale() {

		$this->processSubmitAccountWholesaleCreateAccount();
		
		if(empty($this->errors)) {
			$customer = $this->context->customer;

			// add customer to wholesale group
			$customer->cleanGroups(); // delete all customer groups
			$customer->addGroups(array((int)$this->wholesale_customer_group));
			
			// disable customer, needs approval
			if($customer->active==1) $customer->toggleStatus();
			
			// send email to admin for approval
			Mail::Send(
				$this->context->language->id,
				'wholesale_registration',
				Mail::l('Wholesale Registration'),
				array(
					'{firstname}' => $customer->firstname,
					'{lastname}' => $customer->lastname,
					'{email}' => $customer->email,
					'{passwd}' => Tools::getValue('passwd')),
				Configuration::get('PS_SHOP_EMAIL'),
				Configuration::get('PS_SHOP_NAME')
			);
			
			
			// now log the customer out
			$customer->logout();
			
			
			//
			// finishing touches from processSubmitAccount()
			//
			if (!$customer->is_guest)
				if (!$this->sendConfirmationMail($customer))
					$this->errors[] = Tools::displayError('The email cannot be sent.');

			
			if ($this->ajax)
			{
				$return = array(
					'hasError' => !empty($this->errors),
					'errors' => $this->errors,
					'isSaved' => true,
					'id_customer' => (int)$this->context->cookie->id_customer,
					'id_address_delivery' => $this->context->cart->id_address_delivery,
					'id_address_invoice' => $this->context->cart->id_address_invoice,
					'token' => Tools::getToken(false)
				);
				die(Tools::jsonEncode($return));
			}

			Tools::redirect('index.php?controller=authentication&layout=wholesale_confirm');
		}
	}
	
	
//
//
// more code here
//
//

}

If you need to edit this file, the above are most likely what you need to edit.  $wholesale_customer_group is the id of the wholesale customer group.  Function processSubmitAccountWholesale adds the customer to the wholesale group, inactivates the account, logs out the user, and sends the notification email to the admin.

 

One other note, if you are are adding this file for the first time, you will need to delete or rename the file /cache/class_index.php for the override to take effect.

 

 

2.  Add the registration template file

/themes/[YOUR_THEME]/authentication_wholesale.tpl

 

This file is just a copy of /themes/[YOUR_THEME]/authentication.tpl, with 2 changes

 

First I changed:

<form action="{$link->getPageLink('authentication', true)|escape:'html':'UTF-8'}" method="post" id="account-creation_form" class="std box">

to this

<form action="{$link->getPageLink('authentication', true, NULL, 'layout=wholesale')|escape:'html':'UTF-8'}" method="post" id="account-creation_form" class="std box">

And changed this

<button type="submit" name="submitAccount" id="submitAccount" class="btn btn-default button button-medium">

to this:

<button type="submit" name="SubmitAccountWholesale" id="SubmitAccountWholesale" class="btn btn-default button button-medium">

3. Add the registration confirmation template

/themes/[YOUR_THEME]/authentication_wholesale_confirm.php

This is just the confirmation page that is shown after registering on the wholesale confirmation account

 

 

4. Add the mail templates

/themes/[YOUR_THEME]/mails/[iSO]/wholesale_registration.html

/themes/[YOUR_THEME]/mails/[iSO]/wholesale_registration.txt

This is the email notification sent to the admin

 

 

That is it.  If everything is done correctly, you will be able to access the separate registration page here:

[YOUR_WEBSITE_ADDRESS]/index.php?controller=authentication&layout=wholesale

 

Here is the full code: attachicon.gifwholesale_registration.zip

Edit: Above link does not seem to work anymore, here is dropbox link: https://www.dropbox.com/s/hu6nc5yy91mupd7/wholesale_registration.zip?dl=0

 

seyi thank you, your solution works like a charm in Presta 1.6.1.6

Link to comment
Share on other sites

Hello masters,

 

I just solve it which is more simple and easy.

 

just copy and duplicate authentication.tpl file in your /themes/[yourtheme]/authentication.tpl.

 

edit: AuthController.php 

Change this line: 

$this->setTemplate(_PS_THEME_DIR_.'authentication.tpl');

 

To:

if(Tools::getValue('secondlayout')){
    $this->setTemplate(_PS_THEME_DIR_.'authentication2.tpl');
}else{
    $this->setTemplate(_PS_THEME_DIR_.'authentication.tpl');

 

}
 
thats all. your url will be /web.site/authentication?secondlayout=true
 
Hope this tip help to someone. 
 
Cheers

 

Link to comment
Share on other sites

  • 4 weeks later...

Not using that version so cant be sure.  Looking at the code though, it should work.  Verify the wholesale email template is in the right location.

Thank you, I found a problem's source elsewhere. During the upgrade, all overrides had been disabled by default. I had to enable them to make the code work again.

 

So I can confirm now - seyi's code works in presta 1.6.1.7 as well! 

 

Once again - thank you for coding this, it saved my life ;)

Link to comment
Share on other sites

  • 3 weeks later...

 

Hello masters,

 

I just solve it which is more simple and easy.

 

just copy and duplicate authentication.tpl file in your /themes/[yourtheme]/authentication.tpl.

 

edit: AuthController.php 

Change this line: 

$this->setTemplate(_PS_THEME_DIR_.'authentication.tpl');

 

To:

if(Tools::getValue('secondlayout')){
    $this->setTemplate(_PS_THEME_DIR_.'authentication2.tpl');
}else{
    $this->setTemplate(_PS_THEME_DIR_.'authentication.tpl');

 

}
 
thats all. your url will be /web.site/authentication?secondlayout=true
 
Hope this tip help to someone. 
 
Cheers

 

 

 

Hello masters,

 

I just solve it which is more simple and easy.

 

just copy and duplicate authentication.tpl file in your /themes/[yourtheme]/authentication.tpl.

 

edit: AuthController.php 

Change this line: 

$this->setTemplate(_PS_THEME_DIR_.'authentication.tpl');

 

To:

if(Tools::getValue('secondlayout')){
    $this->setTemplate(_PS_THEME_DIR_.'authentication2.tpl');
}else{
    $this->setTemplate(_PS_THEME_DIR_.'authentication.tpl');

 

}
 
thats all. your url will be /web.site/authentication?secondlayout=true
 
Hope this tip help to someone. 
 
Cheers

 

did not work, prestashop 1.6.0.9

Link to comment
Share on other sites

 

Hi,

This not work in v.1.6.1.1 ?

 

Have tried it and the result is the following:

-Admin Receives no mail about registration

- Wholesale customer is registered in the standard customer group (ID1) and are automatically logged on customer backoffice.

 

From what I understand of these modified codes, the following happen:

 

- Customer group "wholesale" should be created (group ID4)

- When a wholesale customer signs up, this customer will automatically be added to wholesale group  ID4, but inactive to admin has approved this customer. Admin will receive an email about this.

 

Have I misunderstood something here?

 

 

I have the same problem, it did not work, prestashop 1.6.0.9.

Link to comment
Share on other sites

  • 1 month later...

Hi!!First of all thank for solution, is great and works perfect!!!IIT IS Absolute perfect, only I would have a doubt: is there any way to make the url friendly???I mean, instead of this:

[YOUR_WEBSITE_ADDRESS]/index.php?controller=authentication&layout=wholesale

 

 

Link to comment
Share on other sites

The more correct solution would be to make a new controller as the solution I created just piggy backed off the customer controller since most of the code would be the same.  But in the end, it is really just preference, as long as the outcome is what you want.

  • Like 1
Link to comment
Share on other sites

Perfect Seyi,  people like you helps a lot!! Thanks so much!! I am very thankfull for your time, this solution has save me a lot of time and energy.

 

I am try to improve your module added a confirmation mail to send to the clients (wholeshales) that has been aproved from the back end, because, I only lack this functionality to have a "whole privated category" only for the customers that are in this group. I have find modules that make it, but it converts all my clients in unactivated, and I only want this group unactive by default, and I want to send their an automatic mail when their accounts(only the accounts in this group) were activated by admin.

 

I have find anyway a solution that used with your module, make that people that are register with your module registration template go directly to my prefer group depends on the fields in the register (for example in my case they has to be more than 100 points of sales) which is a field that I added manually to your register form. Is called customer auto groups, it is here. https://github.com/nenes25/prestashop_customerautogroups I shared because some people can find it usefull.

 

 My prestashop version is 1.6.1.7 and it works perfect with your module. I only have to achieve to send a mail to my clients registered in the group 4 (wholesale) when I active their accounts, then they will can access to a private category of my shop.

 

In the other hand, not related to this, I am working on a module too for the map (contact store) stores section.It will do a filter by any categories that I have created in the back end section.

But is a hard and long way so, when I had finished, I will share here in the forums.

 

Sorry for my bad english :-))

 

Thanks comunity for all your time!!!

Link to comment
Share on other sites

×
×
  • Create New...