From 55c6e8e3f315d4c3f03ecc4e07091b94e2144921 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 14 Apr 2023 10:17:24 +0530 Subject: [PATCH] fix address not updating on admin address and order page --- classes/Address.php | 9 ++++++--- controllers/admin/AdminAddressesController.php | 7 ++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/classes/Address.php b/classes/Address.php index f8c03294a..afd5df5ba 100644 --- a/classes/Address.php +++ b/classes/Address.php @@ -251,10 +251,13 @@ class AddressCore extends ObjectModel $errors = parent::validateController($htmlentities); // for customer address we need to check of customer address already exists. - if ($idCustomer = Tools::getValue('id_customer')) { - if ($id_address = Customer::getCustomerIdAddress($idCustomer)) { + // if we are editing an address we do not need to validate already created address. + if (!Validate::isLoadedObject($this)) { + if ($idCustomer = Tools::getValue('id_customer')) { + if ($id_address = Customer::getCustomerIdAddress($idCustomer)) { - $errors[] = sprintf(Tools::displayError('Customer address already exists. Id address: #%d'), $id_address); + $errors[] = sprintf(Tools::displayError('Customer address already exists. Id address: #%d'), $id_address); + } } } diff --git a/controllers/admin/AdminAddressesController.php b/controllers/admin/AdminAddressesController.php index db6f0c540..beac77b2d 100644 --- a/controllers/admin/AdminAddressesController.php +++ b/controllers/admin/AdminAddressesController.php @@ -366,7 +366,12 @@ class AdminAddressesControllerCore extends AdminController $this->redirect_after = false; } - $address = new Address(); + if ($idAddress = Tools::getValue('id_address')) { + $address = new Address($idAddress); + } else { + $address = new Address(); + } + $this->errors = $address->validateController(); // Transform e-mail in id_customer for parent processing