Updated and optmized the code for address updation from the order detail page

This commit is contained in:
vishalsingh.qlo325
2025-05-12 17:06:41 +05:30
parent 854903e2ad
commit 2d85ca45a9
2 changed files with 22 additions and 19 deletions

View File

@@ -214,19 +214,8 @@ class AddressCore extends ObjectModel
}
// If address is already used in any order, it will not be edited directly, set address to "deleted" and create a new address
if ($usedCount = $this->isUsed()) {
if ($this->deleted == 0) {
return $this->updateUsedAddress($this);
} else if ($usedCount >= 2
&& ($idOrder = Tools::getValue('id_order')) // if address is updated from the order detail page
&& (Validate::isLoadedObject($objOrder = new Order((int) $idOrder)))
) {
$objAddress = clone $this;
$objAddress->deleted = 1;
$objAddress->add();
return $objAddress;
}
if ($this->isUsed() && $this->deleted == 0) {
return $this->updateUsedAddress($this);
}
return parent::update($null_values);