Skip to content

Commit 866070b

Browse files
committed
fix: filter default card brand by key instead of localized title
Classic checkout was filtering card brands by title ('Card') which fails on non-English sites where title is translated. Now filters by key ('default') matching block checkout behavior.
1 parent 3ed2918 commit 866070b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

assets/js/monei-cc-classic.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -367,19 +367,19 @@
367367
}
368368

369369
let html = '<span class="monei-card-brands">';
370-
const brands = Object.values( wc_monei_params.cardBrands );
370+
const brandKeys = Object.keys( wc_monei_params.cardBrands ).filter(
371+
( key ) => key !== 'default'
372+
);
371373

372-
// Skip the 'default' brand
373-
for ( let i = 0; i < brands.length; i++ ) {
374-
if ( brands[ i ].title === 'Card' ) {
375-
continue;
376-
}
374+
// Render each brand icon
375+
for ( let i = 0; i < brandKeys.length; i++ ) {
376+
const brand = wc_monei_params.cardBrands[ brandKeys[ i ] ];
377377
html +=
378378
'<img src="' +
379-
brands[ i ].url +
379+
brand.url +
380380
'" ' +
381381
'alt="' +
382-
brands[ i ].title +
382+
brand.title +
383383
'" ' +
384384
'class="card-brand-icon" />';
385385
}

0 commit comments

Comments
 (0)