diff --git a/src/models/Order.php b/src/models/Order.php index a41a89a..deccba7 100644 --- a/src/models/Order.php +++ b/src/models/Order.php @@ -33,7 +33,7 @@ public function __construct( array $line_items = [], ?int $order_id = null, ?DateTime $pickup_date = null, - OrderStatus $status = OrderStatus::PENDING, // Default to 'pending', + OrderStatus $status = OrderStatus::PENDING, DateTime $created_date = new DateTime(), ) { $this->store_id = $store_id; @@ -273,7 +273,7 @@ public function cancelOrder(): void $stm->execute(['order_id' => $this->order_id]); $conn->commit(); - } catch (PDOException $e) { + } catch (PDOException) { $conn->rollBack(); } finally { $conn = null; diff --git a/src/models/OrderProduct.php b/src/models/OrderProduct.php index 5f66612..f00eb04 100644 --- a/src/models/OrderProduct.php +++ b/src/models/OrderProduct.php @@ -6,8 +6,6 @@ use Exception; use Steamy\Core\Model; -use Steamy\Model\OrderMilkType; -use Steamy\Model\OrderCupSize; class OrderProduct { @@ -74,16 +72,6 @@ public function validate(): array $errors['quantity'] = 'Quantity must be a positive integer'; } - // Validate milk type using enum values - if (!in_array($this->milk_type, [OrderMilkType::ALMOND, OrderMilkType::COCONUT, OrderMilkType::OAT, OrderMilkType::SOY])) { - $errors['milk_type'] = 'Milk type invalid'; - } - - // Validate cup size using enum values - if (!in_array($this->cup_size, [OrderCupSize::SMALL, OrderCupSize::MEDIUM, OrderCupSize::LARGE])) { - $errors['cup_size'] = 'Cup size type invalid'; - } - if ($this->unit_price <= 0) { $errors['unit_price'] = 'Unit price cannot be negative'; } @@ -111,8 +99,8 @@ public static function getByID(int $order_id, int $product_id): ?OrderProduct return new OrderProduct( product_id: $result->product_id, - cup_size: $result->cup_size, - milk_type: $result->milk_type, + cup_size: OrderCupSize::from($result->cup_size), + milk_type: OrderMilkType::from($result->milk_type), quantity: $result->quantity, unit_price: (float)$result->unit_price, order_id: $result->order_id, @@ -189,8 +177,8 @@ public function toArray(): array return [ 'order_id' => $this->order_id, 'product_id' => $this->product_id, - 'cup_size' => $this->cup_size->value, - 'milk_type' => $this->milk_type->value, + 'cup_size' => $this->cup_size->value, + 'milk_type' => $this->milk_type->value, 'quantity' => $this->quantity, 'unit_price' => $this->unit_price, ]; diff --git a/src/views/Contact.php b/src/views/Contact.php index 8a242a2..4d74a91 100644 --- a/src/views/Contact.php +++ b/src/views/Contact.php @@ -9,6 +9,7 @@ * @var string $defaultLastName Default value for last name input field * @var string $defaultEmail Default value for email input field * @var string $defaultMessage Default value for message textarea + * @var bool $contact_us_successful Whether contact was successful * @var array $errors Array of validation errors */ @@ -19,28 +20,40 @@

Contact Us

- - + + - + - - + + - + - + - + - - + + - +
@@ -50,7 +63,8 @@ >

Thank You for Contacting Us! 🔎

-

Your message has been successfully sent. Our team will review your inquiry and get back to you shortly. We appreciate your interest in our services.

+

Your message has been successfully sent. Our team will review your inquiry and get back to you shortly. We + appreciate your interest in our services.

diff --git a/src/views/mails/OrderConfirmation.php b/src/views/mails/OrderConfirmation.php index ff7fbed..541557a 100644 --- a/src/views/mails/OrderConfirmation.php +++ b/src/views/mails/OrderConfirmation.php @@ -16,7 +16,6 @@ */ -use Steamy\Model\Client; use Steamy\Model\Order; use Steamy\Model\Store; @@ -66,10 +65,10 @@ $quantity = $orderProduct->getQuantity(); $pricePerUnit = $orderProduct->getUnitPrice(); $subtotal = $pricePerUnit * $quantity; - $size = htmlspecialchars(ucfirst($orderProduct->getCupSize())); + $size = htmlspecialchars(ucfirst($orderProduct->getCupSize()->value)); $total += $subtotal; $milk = htmlspecialchars( - ucfirst($orderProduct->getMilkType()) + ucfirst($orderProduct->getMilkType()->value) ); echo <<< HTML @@ -91,7 +90,7 @@ -

Your order is now being processed and you will receive a notification once your order is ready. If you have any +

Your order is now being processed, and you will receive a notification once your order is ready. If you have any questions, feel free to call our store at getPhoneNo() ?>.

Best Regards,