fix: hide checkout left column when there's nothing to put in it
The left column used to always render when stripe was enabled and the shop was stripe-ready, even when the buyer had no card on file — showing a duplicate "Add a credit card payment method" CTA next to the right-column "Pay with Credit Card — Add Card" button. Two identical CTAs in two columns read as a broken page. Left column now renders only when it has concrete content: - an Active Card to display, or - an Active Shipping Address for a physical product in the cart. Otherwise the page collapses to a centered single column (the CSS :has(.checkout-left) selector already handled this layout case). Existing assertion test_cart_checkout_for_shop now also asserts the left-column "no card configured" copy no longer appears.
This commit is contained in:
parent
c06be6b37d
commit
8633470a65
2 changed files with 18 additions and 12 deletions
|
|
@ -5,11 +5,18 @@
|
|||
|
||||
<section class="checkout-page">
|
||||
|
||||
{% if (stripe_enabled and request.shop and request.shop.is_stripe_ready) or request.user.active_address %}
|
||||
{# Left column renders only when there's something concrete to show:
|
||||
an Active Card to confirm, or an Active Shipping Address for a
|
||||
physical product. The "no card yet" CTA used to live here, but
|
||||
it's redundant now that the right column has a prominent
|
||||
"Pay with Credit Card — Add Card" button alongside PayPal /
|
||||
crypto. Two duplicate CTAs read as a broken page. #}
|
||||
{% set has_card_section = stripe_enabled and request.shop and request.shop.is_stripe_ready and active_card %}
|
||||
{% set has_shipping_section = request.user.active_address and cart.physical_products %}
|
||||
{% if has_card_section or has_shipping_section %}
|
||||
<section class="checkout-left well">
|
||||
|
||||
{% if stripe_enabled and request.shop and request.shop.is_stripe_ready %}
|
||||
{% if active_card %}
|
||||
{% if has_card_section %}
|
||||
<h2><b>Active Card</b></h2>
|
||||
|
||||
{{ stripe.display_card(active_card, actions=False) }}
|
||||
|
|
@ -19,19 +26,13 @@
|
|||
{% if request.shop and request.shop.is_ready_for_payment(request) %}
|
||||
<a href="/billing" class="product-edit-button mps-button">Use a different card</a>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<h2><b>Payment</b></h2>
|
||||
<p>No active credit card payment method configured.</p>
|
||||
<p><a href="/billing" class="add-payment-method-button mps-button">Add a credit card payment method</a></p>
|
||||
<br>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if request.user.active_address and cart.physical_products %}
|
||||
{% if has_shipping_section %}
|
||||
<h2>Active Shipping Address</h2>
|
||||
<pre>{{- request.user.active_address.data -}}</pre>
|
||||
<a href="/u/addresses" class="product-edit-button mps-button">Use a different address</a>
|
||||
{% endif %}
|
||||
<a href="/u/addresses" class="product-edit-button mps-button">Use a different address</a>
|
||||
{% endif %}
|
||||
|
||||
</section>
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -636,6 +636,11 @@ class AuthenticatedFunctionalTests(_AuthenticatedBase):
|
|||
# is buried in the left panel and easy to miss next to PayPal /
|
||||
# crypto CTAs.
|
||||
self.assertIn("Pay with Credit Card", checkout_body)
|
||||
# The left column no longer renders its "no card configured"
|
||||
# branch — the right-column CTA is the single place to add a
|
||||
# card. Two duplicate CTAs read as a broken page.
|
||||
self.assertNotIn("No active credit card payment method configured", checkout_body)
|
||||
self.assertNotIn("Add a credit card payment method", checkout_body)
|
||||
|
||||
def test_cart_checkout_logic_with_none_stripe_user_shop(self):
|
||||
"""Test the specific logic that was causing AttributeError in cart checkout.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue