Skip to content

FIX: When order becomes free through coupon, avoid payment method load#15

Open
carl-lee-lu wants to merge 1 commit intospree:mainfrom
carl-lee-lu:fix/payment-methods-handle-free-order
Open

FIX: When order becomes free through coupon, avoid payment method load#15
carl-lee-lu wants to merge 1 commit intospree:mainfrom
carl-lee-lu:fix/payment-methods-handle-free-order

Conversation

@carl-lee-lu
Copy link

@carl-lee-lu carl-lee-lu commented Mar 2, 2026

When an order becomes fully paid through a promo code, the payment method tries to get loaded but in the case of stripe you don't create a payment intent for a free order which causes the route constraint to break. Additionally the order needs to be placed on the payment screen, not pay

This screenshot was with the change to payment rerquired but without updating the rest of the partial
Screenshot 2026-02-24 at 13 03 21

This is with the full changes in place and a free coupon
Screenshot 2026-02-24 at 15 09 08

Additionally tested with a gift card
Screenshot 2026-02-24 at 15 03 44

And store credit
Screenshot 2026-02-24 at 14 59 25

Summary by CodeRabbit

  • Bug Fixes
    • Improved payment method section visibility during checkout to display only when payment is required.
    • Enhanced store credit messaging logic to display appropriately based on order state.
    • Refined payment submission button display to appear only when necessary during the checkout process.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 296da9b and 15ff3ae.

📒 Files selected for processing (1)
  • storefront/app/views/spree/checkout/_payment_methods.html.erb

Walkthrough

Refactored conditional logic in the payment methods template to simplify visibility controls. The initial condition was simplified to use unless payment_required?, store credit messaging conditional was updated to elsif, and the payment submission button was moved under a payment-required conditional.

Changes

Cohort / File(s) Summary
Payment Methods Template
storefront/app/views/spree/checkout/_payment_methods.html.erb
Restructured conditional logic to simplify payment method visibility control and relocated payment submission button under a payment_required? conditional; changed store credit messaging to use elsif instead of else.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A rabbit hops through conditionals today,
Simplifying logic in every way—
Unless and elsif dance in harmony,
Payment methods flow more naturally!
Buttons nested tight, the flow's just right. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: preventing payment method loading when an order becomes free through a coupon, which aligns with the code changes that refactor payment method visibility logic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant