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.phpopen 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