From 5e121da4ed154c77ba92e59d15fe6661905feafb Mon Sep 17 00:00:00 2001 From: Obinna Elvis Okechukwu Date: Mon, 3 Aug 2026 06:17:44 -0500 Subject: [PATCH 1/2] fix(checkout): persist recomputed order total when payment method changes Selecting a new payment method only saved the payment code, so a stale pre-fee order_total (set earlier in the request) could be written to the database alongside it. --- src/Livewire/Checkout.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Livewire/Checkout.php b/src/Livewire/Checkout.php index 4362457..aec5c18 100644 --- a/src/Livewire/Checkout.php +++ b/src/Livewire/Checkout.php @@ -299,8 +299,11 @@ public function onChoosePayment($code): void $this->checkoutForm->getField('payment')->value = $code; $this->orderManager->applyCurrentPaymentFee($payment->code); - if ($this->order->payment !== $code) { - $this->order->updateQuietly(['payment' => $code]); + if ($this->order->payment !== $code || $this->order->order_total !== $this->cartManager->getCart()->total()) { + $this->order->updateQuietly([ + 'payment' => $code, + 'order_total' => $this->cartManager->getCart()->total(), + ]); } $this->order = null; From 9ac8ba24a60c80c9466a4f74be5bfd17f310f5d1 Mon Sep 17 00:00:00 2001 From: Obinna Elvis Okechukwu Date: Mon, 3 Aug 2026 06:27:52 -0500 Subject: [PATCH 2/2] refactor(checkout): cache cart total once in onChoosePayment Avoids computing the cart total twice and guarantees the comparison and the persisted value are the same total. --- src/Livewire/Checkout.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Livewire/Checkout.php b/src/Livewire/Checkout.php index aec5c18..709da18 100644 --- a/src/Livewire/Checkout.php +++ b/src/Livewire/Checkout.php @@ -299,10 +299,12 @@ public function onChoosePayment($code): void $this->checkoutForm->getField('payment')->value = $code; $this->orderManager->applyCurrentPaymentFee($payment->code); - if ($this->order->payment !== $code || $this->order->order_total !== $this->cartManager->getCart()->total()) { + $cartTotal = $this->cartManager->getCart()->total(); + + if ($this->order->payment !== $code || $this->order->order_total !== $cartTotal) { $this->order->updateQuietly([ 'payment' => $code, - 'order_total' => $this->cartManager->getCart()->total(), + 'order_total' => $cartTotal, ]); }