Hi All,
I am using version 1.7.8.6
I changed classes/form/CustomerFormatter.php line 212 set required true to require birthday.
if ($this->ask_for_birthdate) {
$format['birthday'] = (new FormField())
->setName('birthday')
->setType('text')
->setLabel(
$this->translator->trans(
'Birthdate',
[],
'Shop.Forms.Labels'
)
)
->setRequired(true)
->addAvailableValue('placeholder', Tools::getDateFormat())
1. should i create a new CustomerFormatter.php and put it in the override/classes/form instead of modifying the root/classes/form/?
2. I added the below code, however, if the age is younger than 18 it says "format should be 05/31/1970." If its 18 and older user can proceed.
How can i change the message to show you must be 18 years or older to proceed?
3. I like to add another condition if greater than 18 but younger than 60.
<?php
//User age verification 18 years and older
class Validate extends ValidateCore
{
public static function isBirthDate($date, $format = 'Y-m-d')
{
if (empty($date) || $date == '0000-00-00') {
return true;
}
$d = DateTime::createFromFormat($format, $date);
if (!empty(DateTime::getLastErrors()['warning_count']) || false === $d) {
return false;
}
$d->add(new DateInterval("P18Y"));
return $d->setTime(0, 0, 0)->getTimestamp() <= time();
}
}
Thanks
-K