Invalidate order cache on updates and adjust delete logic for order_items_o

- Added `objectChanged()` to notify the order object when items are updated or deleted.
- Refactored `delete()` method to ensure the order is informed before executing the database query.
This commit is contained in:
Jeppe Bundgaard
2025-09-24 13:00:38 +02:00
parent 11ac183fb1
commit 4c7084ee7b
+5 -2
View File
@@ -197,6 +197,8 @@ class order_items_o extends db
if ($notes) {
$this->notes->set($notes);
}
// Invalidate the order cache
$order->objectChanged();
} catch (Exception $e) {
$response->error($e->getMessage());
@@ -212,10 +214,11 @@ class order_items_o extends db
// TODO: Implement delete() method instead
global $db;
$this->id = $id;
$sql = "DELETE FROM $this->table WHERE id = $this->id or related_item_id = $this->id";
$db->query($sql);
$this->select($this->id);
// Inform the order object that an item has been removed
$this->getOrder()->objectChanged();
$sql = "DELETE FROM $this->table WHERE id = $this->id or related_item_id = $this->id";
$db->query($sql);
}
public function getItemAsArray(): array