Updated and optmized the code for address updation from the order detail page
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user