diff --git a/src/models/Order.php b/src/models/Order.php
index 8af5b10..cd0ca34 100644
--- a/src/models/Order.php
+++ b/src/models/Order.php
@@ -208,52 +208,61 @@ public function addOrderProduct(OrderProduct $newOrderProduct): bool
public function calculateTotalPrice(): float
{
- // TODO: Use a single query to calculate total price
- return 0;
+ $query = "SELECT SUM(unit_price * quantity) AS total_price
+ FROM order_product WHERE order_id = :order_id";
+
+ $result = self::get_row($query, ['order_id' => $this->order_id]);
+
+ if ($result) {
+ return (float) $result->total_price;
+ }
+
+ return 0.0;
}
public function toHTML(): string
{
- // TODO: get order products and names of each product using a single query
-
- $html = <<
-
-
-
-
- Product
- Quantity
- Price per Unit
- Total Price
-