Prestashop .7.6 and 1.7.7 make birthday (age) mandatory and limit 18+ years old
Create a new override file in /override/classes/form/CustomerFormatter.php $this->language = $language; parent::__construct($translator,$language); } public function getFormat() { $format = parent::getFormat(); //override/add all customisations for fields $format[‘birthday’] = (new FormField()) ->setName(‘birthday’) ->setType(‘text’) ->setLabel( $this->translator->trans( ‘Birthdate’, [], ‘Shop.Forms.Labels’ ) ) ->addAvailableValue(‘placeholder’, Tools::getDateFormat()) ->addAvailableValue( ‘comment’, $this->translator->trans(‘(E.g.: %date_format%)’, array(‘%date_format%’ => Tools::formatDateStr(’31 May 1970′)), ‘Shop.Forms.Help’) ) ->setRequired(true); //As addConstraints method is private we need to call the logic here. We don’t need to iterate over all the fields again, just the changed ones. $constraints = Customer::$definition[‘fields’]; $field = $format[‘birthday’]; if (!empty($constraints[$field->getName()][‘validate’])) { $field->addConstraint( $constraints[$field->getName()][‘validate’] ); } return $format; } } Create a new file in /override/classes/Validate.php } } Change translation to include “You must have 18+ years” in the error message shown in front office. Remember to restart php (fpm or apache) to clear opcache and delete /var/cache/* data to regenerate override sudo service php7.2-fpm restart sudo rm -rf var/cache/*