diff --git a/app/Traits/Order/WithMember.php b/app/Traits/Order/WithMember.php index cb638e1..ea6ed7e 100644 --- a/app/Traits/Order/WithMember.php +++ b/app/Traits/Order/WithMember.php @@ -43,7 +43,16 @@ public function updatedFormVoucherId(?string $voucherId = null): void $subtotal = $this->getSubtotal(); - $this->voucherDiscount = $this->calculateDiscount($subtotal, $voucher->id); + $voucherDiscountResult = $this->calculateDiscount($subtotal, $voucher->id); + + if (is_array($voucherDiscountResult)) { + // Error case - reset voucher discount and show error + $this->voucherDiscount = 0; + $this->form->voucher_id = ''; // Reset voucher selection + $this->toast($voucherDiscountResult['message'], 'Error', 'danger'); + } else { + $this->voucherDiscount = $voucherDiscountResult; + } $this->total = $this->getTotal(); }