Jump to content

Edit History

amorxoigel

amorxoigel


mistake.

On 4/18/2019 at 6:53 PM, mma87 said:

Hello,

I'm using PS 1.7.5.1 and I made a customization to insert email and password confirmation:

BACKUP FIRST!!

 

Download those 2 files


/classes/form/CustomerFormatter.php

/classes/form/CustomerForm.php

open the file CustomerFormatter.php and search


$format['email'] = (new FormField())

paste above


	$format['email'] = (new FormField())
            ->setName('email')
            ->setType('email')
            ->setLabel(
                $this->translator->trans(
                    'Email', [], 'Shop.Forms.Labels'
                )
            )
            ->setRequired(true)
        ;

this code:


		$format['conf_email'] = (new FormField)
			->setName('conf_email')
			->setLabel(
				$this->translator->trans(
					'Confirm e-mail', [], 'Shop.Forms.Labels'
				)
			)
			->setRequired(true)
		;

Then after:


        if ($this->ask_for_new_password) {
            $format['new_password'] = (new FormField())
                ->setName('new_password')
                ->setType('password')
                ->setLabel(
                    $this->translator->trans(
                        'New password', [], 'Shop.Forms.Labels'
                    )
                )
            ;
        }

paste this code:


		$format['conf_password'] = (new FormField)
			->setName('conf_password')
			->setType('password')
			->setLabel(
				$this->translator->trans(
					'Confirm password', [], 'Shop.Forms.Labels'
				)
			)
			->setRequired(true)
		;

 

Now open CustomerForm.php and search 


public function validate()

after this code:


	$emailField = $this->getField('email');
        $id_customer = Customer::customerExists($emailField->getValue(), true, true);
        $customer = $this->getCustomer();
        if ($id_customer && $id_customer != $customer->id) {
            $emailField->addError($this->translator->trans(
                'The email is already used, please choose another one or sign in', array(), 'Shop.Notifications.Error'
            ));
        }

Paste the following code:


//Confirm Email - check if is the same
		$confEmailField = $this->getField('conf_email');
		$emailValue = $emailField->getValue();
		$confEmailValue = $confEmailField->getValue();
		if ($emailValue != $confEmailValue) {
            $confEmailField->addError($this->translator->trans(
                "The email and the confirmation email don't match", array(), 'Shop.Notifications.Error'
            ));
        }
		

		//Confirm password - check if is the same
		$passwField = $this->getField('password');
		$confPasswField = $this->getField('conf_password');
		$passwordValue = $passwField->getValue();
		$confPasswValue = $confPasswField->getValue();
		if ($passwordValue != $confPasswValue) {
            $confPasswField->addError($this->translator->trans(
                "The password and the confirmation password don't match", array(), 'Shop.Notifications.Error'
            ));
        }

 

Now upload those 2 files in:


/override/classes/form/

Clear the cache

That's it!

 

ty for ur solution but still it give me an error
"

Parse error: syntax error, unexpected '$emailValue' (T_VARIABLE)

"
on CustomerForm.php

Any ideas how to solve it?



prestashop 1.7.5

amorxoigel

amorxoigel


mistake

On 4/18/2019 at 6:53 PM, mma87 said:

Hello,

I'm using PS 1.7.5.1 and I made a customization to insert email and password confirmation:

BACKUP FIRST!!

 

Download those 2 files


/classes/form/CustomerFormatter.php

/classes/form/CustomerForm.php

open the file CustomerFormatter.php and search


$format['email'] = (new FormField())

paste above


	$format['email'] = (new FormField())
            ->setName('email')
            ->setType('email')
            ->setLabel(
                $this->translator->trans(
                    'Email', [], 'Shop.Forms.Labels'
                )
            )
            ->setRequired(true)
        ;

this code:


		$format['conf_email'] = (new FormField)
			->setName('conf_email')
			->setLabel(
				$this->translator->trans(
					'Confirm e-mail', [], 'Shop.Forms.Labels'
				)
			)
			->setRequired(true)
		;

Then after:


        if ($this->ask_for_new_password) {
            $format['new_password'] = (new FormField())
                ->setName('new_password')
                ->setType('password')
                ->setLabel(
                    $this->translator->trans(
                        'New password', [], 'Shop.Forms.Labels'
                    )
                )
            ;
        }

paste this code:


		$format['conf_password'] = (new FormField)
			->setName('conf_password')
			->setType('password')
			->setLabel(
				$this->translator->trans(
					'Confirm password', [], 'Shop.Forms.Labels'
				)
			)
			->setRequired(true)
		;

 

Now open CustomerForm.php and search 


public function validate()

after this code:


	$emailField = $this->getField('email');
        $id_customer = Customer::customerExists($emailField->getValue(), true, true);
        $customer = $this->getCustomer();
        if ($id_customer && $id_customer != $customer->id) {
            $emailField->addError($this->translator->trans(
                'The email is already used, please choose another one or sign in', array(), 'Shop.Notifications.Error'
            ));
        }

Paste the following code:


//Confirm Email - check if is the same
		$confEmailField = $this->getField('conf_email');
		$emailValue = $emailField->getValue();
		$confEmailValue = $confEmailField->getValue();
		if ($emailValue != $confEmailValue) {
            $confEmailField->addError($this->translator->trans(
                "The email and the confirmation email don't match", array(), 'Shop.Notifications.Error'
            ));
        }
		

		//Confirm password - check if is the same
		$passwField = $this->getField('password');
		$confPasswField = $this->getField('conf_password');
		$passwordValue = $passwField->getValue();
		$confPasswValue = $confPasswField->getValue();
		if ($passwordValue != $confPasswValue) {
            $confPasswField->addError($this->translator->trans(
                "The password and the confirmation password don't match", array(), 'Shop.Notifications.Error'
            ));
        }

 

Now upload those 2 files in:


/override/classes/form/

Clear the cache

That's it!

 

ty for ur solution but still it give me an error
"

Parse error: syntax error, unexpected '$emailValue' (T_VARIABLE)

"
on CustomerFormatter.php

Any ideas how to solve it?



prestashop 1.7.5

amorxoigel

amorxoigel


mistake

On 4/18/2019 at 6:53 PM, mma87 said:

Hello,

I'm using PS 1.7.5.1 and I made a customization to insert email and password confirmation:

BACKUP FIRST!!

 

Download those 2 files


/classes/form/CustomerFormatter.php

/classes/form/CustomerForm.php

open the file CustomerFormatter.php and search


$format['email'] = (new FormField())

paste above


	$format['email'] = (new FormField())
            ->setName('email')
            ->setType('email')
            ->setLabel(
                $this->translator->trans(
                    'Email', [], 'Shop.Forms.Labels'
                )
            )
            ->setRequired(true)
        ;

this code:


		$format['conf_email'] = (new FormField)
			->setName('conf_email')
			->setLabel(
				$this->translator->trans(
					'Confirm e-mail', [], 'Shop.Forms.Labels'
				)
			)
			->setRequired(true)
		;

Then after:


        if ($this->ask_for_new_password) {
            $format['new_password'] = (new FormField())
                ->setName('new_password')
                ->setType('password')
                ->setLabel(
                    $this->translator->trans(
                        'New password', [], 'Shop.Forms.Labels'
                    )
                )
            ;
        }

paste this code:


		$format['conf_password'] = (new FormField)
			->setName('conf_password')
			->setType('password')
			->setLabel(
				$this->translator->trans(
					'Confirm password', [], 'Shop.Forms.Labels'
				)
			)
			->setRequired(true)
		;

 

Now open CustomerForm.php and search 


public function validate()

after this code:


	$emailField = $this->getField('email');
        $id_customer = Customer::customerExists($emailField->getValue(), true, true);
        $customer = $this->getCustomer();
        if ($id_customer && $id_customer != $customer->id) {
            $emailField->addError($this->translator->trans(
                'The email is already used, please choose another one or sign in', array(), 'Shop.Notifications.Error'
            ));
        }

Paste the following code:


//Confirm Email - check if is the same
		$confEmailField = $this->getField('conf_email');
		$emailValue = $emailField->getValue();
		$confEmailValue = $confEmailField->getValue();
		if ($emailValue != $confEmailValue) {
            $confEmailField->addError($this->translator->trans(
                "The email and the confirmation email don't match", array(), 'Shop.Notifications.Error'
            ));
        }
		

		//Confirm password - check if is the same
		$passwField = $this->getField('password');
		$confPasswField = $this->getField('conf_password');
		$passwordValue = $passwField->getValue();
		$confPasswValue = $confPasswField->getValue();
		if ($passwordValue != $confPasswValue) {
            $confPasswField->addError($this->translator->trans(
                "The password and the confirmation password don't match", array(), 'Shop.Notifications.Error'
            ));
        }

 

Now upload those 2 files in:


/override/classes/form/

Clear the cache

That's it!

 

Thanks dude for ur help! Still it gave me an error.
"

(1/1) FatalThrowableError

Parse error: syntax error, unexpected '}'

"

it doesnt like the final { of  "//confirm password -check if is the same"
any ideas?
i copy pasted well and if i remove this part it works and ask for confirmation email but i'm not able to make it works for password as well

prestashop 1.7.5

amorxoigel

amorxoigel

On 4/18/2019 at 6:53 PM, mma87 said:

Hello,

I'm using PS 1.7.5.1 and I made a customization to insert email and password confirmation:

BACKUP FIRST!!

 

Download those 2 files


/classes/form/CustomerFormatter.php

/classes/form/CustomerForm.php

open the file CustomerFormatter.php and search


$format['email'] = (new FormField())

paste above


	$format['email'] = (new FormField())
            ->setName('email')
            ->setType('email')
            ->setLabel(
                $this->translator->trans(
                    'Email', [], 'Shop.Forms.Labels'
                )
            )
            ->setRequired(true)
        ;

this code:


		$format['conf_email'] = (new FormField)
			->setName('conf_email')
			->setLabel(
				$this->translator->trans(
					'Confirm e-mail', [], 'Shop.Forms.Labels'
				)
			)
			->setRequired(true)
		;

Then after:


        if ($this->ask_for_new_password) {
            $format['new_password'] = (new FormField())
                ->setName('new_password')
                ->setType('password')
                ->setLabel(
                    $this->translator->trans(
                        'New password', [], 'Shop.Forms.Labels'
                    )
                )
            ;
        }

paste this code:


		$format['conf_password'] = (new FormField)
			->setName('conf_password')
			->setType('password')
			->setLabel(
				$this->translator->trans(
					'Confirm password', [], 'Shop.Forms.Labels'
				)
			)
			->setRequired(true)
		;

 

Now open CustomerForm.php and search 


public function validate()

after this code:


	$emailField = $this->getField('email');
        $id_customer = Customer::customerExists($emailField->getValue(), true, true);
        $customer = $this->getCustomer();
        if ($id_customer && $id_customer != $customer->id) {
            $emailField->addError($this->translator->trans(
                'The email is already used, please choose another one or sign in', array(), 'Shop.Notifications.Error'
            ));
        }

Paste the following code:


//Confirm Email - check if is the same
		$confEmailField = $this->getField('conf_email');
		$emailValue = $emailField->getValue();
		$confEmailValue = $confEmailField->getValue();
		if ($emailValue != $confEmailValue) {
            $confEmailField->addError($this->translator->trans(
                "The email and the confirmation email don't match", array(), 'Shop.Notifications.Error'
            ));
        }
		

		//Confirm password - check if is the same
		$passwField = $this->getField('password');
		$confPasswField = $this->getField('conf_password');
		$passwordValue = $passwField->getValue();
		$confPasswValue = $confPasswField->getValue();
		if ($passwordValue != $confPasswValue) {
            $confPasswField->addError($this->translator->trans(
                "The password and the confirmation password don't match", array(), 'Shop.Notifications.Error'
            ));
        }

 

Now upload those 2 files in:


/override/classes/form/

Clear the cache

That's it!

 

Thanks dude for ur help! Still it gave me an error.
"

(1/1) FatalThrowableError

Parse error: syntax error, unexpected '}'

"

it doesnt like the final { of  "//confirm password -check if is the same"
any ideas?
i copy pasted well and if i remove this part it works and ask for confirmation email but i'm not able to make it works for password as well

prestashop 1.7.5

×
×
  • Create New...