I'm working with a one-page checkout process, where cart contents, account info, billing, payment, and coupon information are all under Checkout. Coupons are handled by commerce_coupon.
This has worked fine, but now I want to allow free orders using 100% discount coupons, and I'm having trouble getting the right payment method selected when the coupon is applied.
To handle order totals being <= 0 because of coupons applied, I've added additional conditions to two payment methods as follows:
Stripe - commerce-order:commerce-order-total > 0.00
No Payment - commerce-order:commerce-order-total <= 0.00
Here's what happens:
When the order arrives at checkout. Stripe is selected as the payment method. When the 100% coupon is applied, the order total drops to zero as expected (through an AJAX refresh), but stripe stays selected as the payment method and the no payment option is not visible. If I reload the page manually, Stripe goes away and the No payment option is selected.
What I want:
Ideally, when a user applies a 100% coupon to the order at checkout, Stripe would disappear from available payment methods and "No payment required" would be automatically selected. Even better would be to also remove the billing information if the order total is <= 0, since there is no reason to collect it.
How can I achieve this?
I'm happy to work directly in code if that's a better approach.