Skip to content

Commit

Permalink
Merge pull request #177 from okom3pom/fix-age
Browse files Browse the repository at this point in the history
Fix age from export customer info
  • Loading branch information
jolelievre authored Jul 15, 2022
2 parents 5c32b6d + c245868 commit bf1ab22
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions psgdpr.php
Original file line number Diff line number Diff line change
Expand Up @@ -1139,12 +1139,10 @@ public function getCustomerNameById($id_customer)
*/
public function getAgeCustomer($id_customer)
{
$value = (int) Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->getValue('SELECT AVG(DATEDIFF("' . date('Y-m-d') . ' 00:00:00", birthday))
return (int) Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->getValue('SELECT TIMESTAMPDIFF(YEAR, birthday, CURDATE()) AS age
FROM `' . _DB_PREFIX_ . 'customer` c
WHERE active = 1
AND id_customer = ' . (int) $id_customer . '
AND birthday IS NOT NULL AND birthday != "0000-00-00" ' . Shop::addSqlRestriction());

return (int) round($value / 365);
}
}

0 comments on commit bf1ab22

Please sign in to comment.