Jump to content

[SOLVED] Letting customer to select the default group


Recommended Posts

Hello there,

I've modified the customer registration and added a pulldown menu on the registration page so that a customer can choose the group they belongs to.

While this works fine, I would like to set the "Default Group" to the one a customer selects. I've looked through files related to the registration process but could not work out how to achieve this.

Could anyone tell me where to change and how?

Thanks in advance,

Rio

Link to comment
Share on other sites

Hi Rocky,

Thanks for the reply. I'm still new to PrestaShop and not 100% sure what 'm doing.

Can you tell me where should the code you mentioned go in? Will it be in the file "authentication.php"?

Also I noticed that in the file "classes/Customer.php", with in the function "add", there is a line that states:

$this->id_default_group = 1;



Will the code you mentioned override this?

Link to comment
Share on other sites

Hi rocky,

Thank you for your input. It's been sorted out and all working now :)

I've inserted a piece of code below in authenticate.php,

$customer->id_default_group = (empty($_POST['group']) ? 1 : intval($_POST['group']));


and commented out the aforementioned line in Customer.php

Cheers!

Link to comment
Share on other sites

  • 1 month later...
  • 5 months later...

Hello,

I'm experiencing similar problems, in the sense that the user does get correctly added to the second group (discount, tax excl. etc.), but the default groups still remains #1. Which should theoretically be a glitch (and actually is: if I edit the newly registered customer without changing anything, I get the standard error: Default customer group must be selected in group box.).

I've changed the following:

> in AuthController.php (PS 1.4), in the if (!$customer->add()) paragraph:

if (Tools::getValue('dni') != '') {$customer->addGroups(array(2)); customer->id_default_group = 2;}



> in Customer.php:
I've commented the line that is mentioned in the 3rd reply, above [$this->id_default_group = 1;]

Any suggestions? Thank you.

Link to comment
Share on other sites

Scratch that, I found a solution here: http://www.prestashop.com/forums/viewthread/2395/P45/third_party_modules/eu_vat_module

if (Tools::getValue('dni') != '')
                   {
                       $customer->cleanGroups();
                       $customer->addGroups(array(2));
                       $customer->id_default_group = 2;
                       $row = array('id_default_group' => intval($customer->id_default_group));
                       Db::getInstance()->AutoExecute(_DB_PREFIX_.'customer', $row, 'UPDATE', "email='".$customer->email."'", 1);
                   }

Link to comment
Share on other sites

  • 11 months later...
×
×
  • Create New...