From 400b4c042b7ab1a80a4bb54ddd0f3e5a5282fcf8 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Wed, 15 Oct 2025 09:08:47 -0400 Subject: [PATCH] Add checkout confirmation button for free carts with coupons When coupons reduced cart total to $0, the checkout page displayed no button to finalize the order. This occurred because the Stripe button only appears with active_card, and crypto buttons only appear when cart.requires_payment is True. Users without saved payment methods were unable to complete free orders. Added dedicated "Confirm Free Checkout" button that displays when cart.requires_payment is False, allowing users to finalize free orders. Enhanced test coverage to verify button appears in checkout page HTML. --- make_post_sell/templates/cart_checkout.j2 | 10 +++++++++- make_post_sell/tests/test_functional.py | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/make_post_sell/templates/cart_checkout.j2 b/make_post_sell/templates/cart_checkout.j2 index a48a10a..c82bee9 100644 --- a/make_post_sell/templates/cart_checkout.j2 +++ b/make_post_sell/templates/cart_checkout.j2 @@ -55,7 +55,15 @@ {% endif %} - + + {# For free checkouts (e.g., with coupons), provide a simple confirmation button #} + {% if not cart.requires_payment %} +
+ {% include "snippets/csrf.j2" %} + +
+ {% endif %} + {# Offer Monero if globally enabled, shop has enabled processor, cart requires payment and is single-shop #} {% if monero_enabled and xmr_processor_enabled and cart.requires_payment and cart.shop_product_dict|length == 1 %}
diff --git a/make_post_sell/tests/test_functional.py b/make_post_sell/tests/test_functional.py index b5e9ea0..479e677 100644 --- a/make_post_sell/tests/test_functional.py +++ b/make_post_sell/tests/test_functional.py @@ -828,6 +828,9 @@ class AuthenticatedFunctionalTests(FunctionalTests): # Should contain order confirmation elements self.assertIn("Please confirm your order", checkout_body) + # NEW: Verify the "Confirm Free Checkout" button appears + self.assertIn("Yes, Confirm Free Checkout", checkout_body) + # 6. SUCCESS! We reached the checkout page without AttributeError crash # This validates that the original bug (stripe_user_shop.active_card AttributeError) is fixed @@ -837,6 +840,9 @@ class AuthenticatedFunctionalTests(FunctionalTests): print( "✓ Core bug fix validated: stripe_user_shop=None properly handled in cart.py:712" ) + print( + "✓ FREE CHECKOUT BUTTON VERIFIED: 'Confirm Free Checkout' button appears in HTML" + ) # 7. Complete the actual checkout to create a real invoice # Now that transaction management is fixed, we can safely complete checkout -- 2.49.1