Skip to content

Commit e827ac1

Browse files
mgascamrtio
authored andcommitted
Fix payment method logos overflow in shortcode checkout (#11117)
1 parent b02cd01 commit e827ac1

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fix
3+
4+
Fix payment method logos overflow in shortcode checkout after adding JCB and UnionPay logos.

client/checkout/classic/event-handlers.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,19 +181,15 @@ jQuery( function ( $ ) {
181181
const paymentMethods = getCardBrands();
182182

183183
function getMaxElements() {
184-
const paymentMethodElement = document.querySelector(
185-
'.payment_method_woocommerce_payments'
186-
);
187-
if ( ! paymentMethodElement ) {
188-
return 4; // Default fallback
189-
}
184+
// Use viewport width as primary indicator (similar to blocks checkout)
185+
const viewportWidth = window.innerWidth;
190186

191-
const elementWidth = paymentMethodElement.offsetWidth;
192-
if ( elementWidth <= 300 ) {
187+
// Specific tablet viewport range (768-781px) - needs room for Test Mode badge
188+
if ( viewportWidth >= 768 && viewportWidth <= 900 ) {
193189
return 1;
194-
} else if ( elementWidth <= 330 ) {
195-
return 2;
196190
}
191+
// Default - show 3 logos + counter badge = 4 visual elements total
192+
return 3;
197193
}
198194

199195
function shouldHavePopover() {

client/checkout/classic/style.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@
4141
img:last-of-type {
4242
margin-right: 0;
4343
}
44+
45+
&-count {
46+
margin-left: 4px;
47+
48+
// Tighter spacing on tablet viewports (768-900px) to conserve space for Test Mode badge
49+
@media ( min-width: 768px ) and ( max-width: 900px ) {
50+
margin-left: 0;
51+
}
52+
}
4453
}
4554
img {
4655
float: right;

0 commit comments

Comments
 (0)