diff --git a/controllers/admin/AdminCustomerPreferencesController.php b/controllers/admin/AdminCustomerPreferencesController.php
index 00c2a9e68..a1e3bb67e 100644
--- a/controllers/admin/AdminCustomerPreferencesController.php
+++ b/controllers/admin/AdminCustomerPreferencesController.php
@@ -99,6 +99,13 @@ class AdminCustomerPreferencesControllerCore extends AdminController
'cast' => 'intval',
'type' => 'bool'
),
+ 'PS_CUSTOMER_BIRTHDATE' => array(
+ 'title' => $this->l('Ask for birth date'),
+ 'hint' => $this->l('Display or not the birth date field.'),
+ 'validation' => 'isBool',
+ 'cast' => 'intval',
+ 'type' => 'bool'
+ ),
'PS_CUSTOMER_NWSL' => array(
'title' => $this->l('Enable newsletter registration'),
'hint' => $this->l('Display or not the newsletter registration tick box.'),
diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php
index 320da13dd..f13822d55 100644
--- a/controllers/front/AuthController.php
+++ b/controllers/front/AuthController.php
@@ -102,6 +102,7 @@ class AuthControllerCore extends FrontController
$newsletter = Configuration::get('PS_CUSTOMER_NWSL') || (Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active);
+ $this->context->smarty->assign('birthday', (bool) Configuration::get('PS_CUSTOMER_BIRTHDATE'));
$this->context->smarty->assign('newsletter', $newsletter);
$this->context->smarty->assign('optin', (bool)Configuration::get('PS_CUSTOMER_OPTIN'));
@@ -463,9 +464,11 @@ class AuthControllerCore extends FrontController
$this->processCustomerNewsletter($customer);
$customer->firstname = Tools::ucwords($customer->firstname);
- $customer->birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days'));
- if (!Validate::isBirthDate($customer->birthday)) {
- $this->errors[] = Tools::displayError('Invalid date of birth.');
+ if (Configuration::get('PS_CUSTOMER_BIRTHDATE')) {
+ $customer->birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days'));
+ if (!Validate::isBirthDate($customer->birthday)) {
+ $this->errors[] = Tools::displayError('Invalid date of birth.');
+ }
}
// New Guest customer
@@ -594,9 +597,11 @@ class AuthControllerCore extends FrontController
$this->processCustomerNewsletter($customer);
- $customer->birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days'));
- if (!Validate::isBirthDate($customer->birthday)) {
- $this->errors[] = Tools::displayError('Invalid date of birth');
+ if (Configuration::get('PS_CUSTOMER_BIRTHDATE')) {
+ $customer->birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days'));
+ if (!Validate::isBirthDate($customer->birthday)) {
+ $this->errors[] = Tools::displayError('Invalid date of birth');
+ }
}
if (!count($this->errors)) {
diff --git a/controllers/front/IdentityController.php b/controllers/front/IdentityController.php
index ea8c2af16..68789e42a 100644
--- a/controllers/front/IdentityController.php
+++ b/controllers/front/IdentityController.php
@@ -53,12 +53,14 @@ class IdentityControllerCore extends FrontController
$email = trim(Tools::getValue('email'));
- if (Tools::getValue('months') != '' && Tools::getValue('days') != '' && Tools::getValue('years') != '') {
- $this->customer->birthday = (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days');
- } elseif (Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '') {
- $this->customer->birthday = null;
- } else {
- $this->errors[] = Tools::displayError('Invalid date of birth.');
+ if (Configuration::get('PS_CUSTOMER_BIRTHDATE')) {
+ if (Tools::getValue('months') != '' && Tools::getValue('days') != '' && Tools::getValue('years') != '') {
+ $this->customer->birthday = (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days');
+ } elseif (Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '') {
+ $this->customer->birthday = null;
+ } else {
+ $this->errors[] = Tools::displayError('Invalid date of birth.');
+ }
}
if (Tools::getIsset('old_passwd')) {
@@ -152,6 +154,7 @@ class IdentityControllerCore extends FrontController
));
$newsletter = Configuration::get('PS_CUSTOMER_NWSL') || (Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active);
+ $this->context->smarty->assign('birthday', (bool) Configuration::get('PS_CUSTOMER_BIRTHDATE'));
$this->context->smarty->assign('newsletter', $newsletter);
$this->context->smarty->assign('optin', (bool)Configuration::get('PS_CUSTOMER_OPTIN'));
diff --git a/install/data/xml/configuration.xml b/install/data/xml/configuration.xml
index 935de20ba..ba0e173c8 100644
--- a/install/data/xml/configuration.xml
+++ b/install/data/xml/configuration.xml
@@ -878,6 +878,9 @@