Skip to content

fix(checkout): persist recomputed order total when payment method changes - #88

Merged
sampoyigi merged 2 commits into
tastyigniter:4.xfrom
obinnaelviso:fix/checkout-payment-fee-not-applying
Aug 4, 2026
Merged

fix(checkout): persist recomputed order total when payment method changes#88
sampoyigi merged 2 commits into
tastyigniter:4.xfrom
obinnaelviso:fix/checkout-payment-fee-not-applying

Conversation

@obinnaelviso

Copy link
Copy Markdown
Contributor

Problem

When switching payment methods during checkout, only the payment code was saved to the order. The order_total attribute in memory had already been computed before the fee was applied for the request, so updateQuietly() could persist a stale, pre-fee total alongside the new payment code.

Companion fix to tastyigniter/ti-ext-cart#138, which addresses why the fee wasn't applying in the first place.

Fix

Checkout::onChoosePayment() now recomputes and saves order_total from the cart alongside payment whenever either has changed, so the persisted order always matches the currently selected payment method.

…nges

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.
Copilot AI review requested due to automatic review settings August 3, 2026 11:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a checkout state persistence issue where changing the payment method could save the new payment code while leaving a stale (pre-fee) order_total on the persisted order, causing the stored order to not match the in-memory/cart-computed total.

Changes:

  • Recompute order_total from the cart after applying the selected payment fee in Checkout::onChoosePayment().
  • Persist both payment and order_total together whenever either value differs from what’s currently stored on the order.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Livewire/Checkout.php Outdated
Avoids computing the cart total twice and guarantees the comparison
and the persisted value are the same total.
@sampoyigi
sampoyigi merged commit 149d88e into tastyigniter:4.x Aug 4, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants