Jump to content

[SOLVED] - AuthController PreProcess function


prestatent
 Share

Recommended Posts

Prestashop 1.5.4.1

 

Hi

 

I am trying to convert an override that I used on a previous version of prestashop (1.4). This overrride created a new user in a different default group depending on the VIP code input.

 

I am now trying to do the same thing on 1.5.4.1 but various things seem to have changed. Function preProcess is now changed to postProcess in presta 1.5. Unfortunately my default group functionality does not now work on 1.5.4.1.

 

See code below:

	public function preProcess()
	{

        $vipmod = new vipgroup_module;
	  
       if (Tools::isSubmit('submitAccount') OR Tools::isSubmit('submitGuestAccount'))
       {
           global $cookie;

        // Check VIP code entered is valid.
           $vipname = Tools::getValue('vipgroup_name');

           if (!isset($vipname) || empty($vipname))
           {
               $this->errors[] = Tools::displayError('VIP Code is required');
           } else {
               if (!Validate::isDiscountName($vipname))
			   {
                   $this->errors[] = Tools::displayError('Invalid VIP Code');
               } else {  
			       $code = $vipmod->getCodeByName($vipname);
				   if (!$code)
				   {
                       $this->errors[] = Tools::displayError('Invalid VIP Code');
				   } else {
                       self::$cookie->id_default_group = (int) $code['id_default_group'];
				   }
			   }
           }
       }

       parent::preProcess();

    }

Can anyone point me in the right direction please?

 

Thanks.

Edited by prestatent (see edit history)

Share this post


Link to post
Share on other sites

Hi Bellini13

 

Have done this already and the validation part of the code works as expected. However, the final part of the update of the new customers default group does not work. Specifically, this line of code:

self::$cookie->id_default_group = (int) $code['id_default_group'];

Thanks for getting back so quickly.

Share this post


Link to post
Share on other sites

Hi

 

The cookie is a global as it stands in 1.4, but this has obviouly changed in 1.5. However the preProcess function obviously did a lookup to get the default group for the vip code entered before adding the customer, whereas in 1.5 the postProcess fucntion does this after, so it looks like I have to find out where to put the code before adding the customer.

Share this post


Link to post
Share on other sites

Anyone else.

 

I need to OVERRIDE the part of the code when I'm creating a new customer. I want to give them a different default customer group rather than the default group assigned to them on registration. I have already done this successfully in Prestashop 1.4, but the code has changed in 1.5 so I need some help.

 

Thanks for reading and hopefully helping.

Edited by prestatent (see edit history)

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More