Updated the process for verifying customer email using ajax process while admin is trying it add/update the customer account

This commit is contained in:
vishalsingh.qlo325
2024-07-04 12:51:53 +05:30
parent 196c37aa1f
commit 2fb73a0b4d
2 changed files with 14 additions and 15 deletions

View File

@@ -1295,20 +1295,18 @@ class AdminCustomersControllerCore extends AdminController
public function ajaxProcessVerifyCustomerEmail()
{
$response = array(
'status' => true
);
if ($email = trim(strval(Tools::getValue('email')))) {
$newIdCustomer = Tools::getValue('id_customer', 0);
$oldIdCustomer = Customer::customerExists($email, true, false);
if ($oldIdCustomer) { // means that the account exists.
$objCustomer = Customer::getByEmail($email, null, false);
if (!$objCustomer // means that the customer was deleted
&& $oldIdCustomer != $newIdCustomer // the admin is trying to update another account in case the new id is not zero
) {
$response['status'] = false;
$response['msg'] = Tools::displayError('The email is already associated with a banned account. Please use a different one.');
}
$response = array('status' => true);
$newIdCustomer = Tools::getValue('id_customer', 0);
if (($email = trim(strval(Tools::getValue('email'))))
&& ($oldIdCustomer = Customer::customerExists($email, true, false))
&& (Validate::isLoadedObject($objCustomer = new Customer($oldIdCustomer)))
&& $oldIdCustomer != $newIdCustomer // the admin is trying to add/update the account
) {
$response['status'] = false;
if ($objCustomer->deleted) {
$response['msg'] = Tools::displayError('The email is already associated with a banned account. Please use a different one.');
} else {
$response['msg'] = Tools::displayError('The email is already associated with a another account. Please use a different one.');
}
}