Hide Apple Pay gateway on ineligible devices

This commit is contained in:
Philipp Stracker 2024-07-24 15:21:09 +02:00
parent 43d7e0788f
commit 3bb0496123
No known key found for this signature in database
2 changed files with 44 additions and 12 deletions

View file

@ -150,13 +150,31 @@ class ApplePayButton {
const idButton = this.buttonConfig.button.wrapper;
if ( ! this.isEligible ) {
jQuery( '#' + idButton ).hide();
jQuery( '#' + idMinicart ).hide();
jQuery( '#express-payment-method-ppcp-applepay' ).hide();
const hideContainers = [
// Payment button (Pay now, smart button block)
`#${ idButton }`,
// Mini Cart button
`#${ idMinicart }`,
// Block Checkout: Express checkout button.
'#express-payment-method-ppcp-applepay',
];
hideContainers.forEach( ( selector ) => {
const elements = document.querySelectorAll( selector );
elements.forEach( ( element ) => {
element.style.display = 'none';
} );
} );
return;
}
// Classic Checkout: Make the Apple Pay gateway visible.
document
.querySelectorAll( 'style#ppcp-hide-apple-pay' )
.forEach( ( el ) => el.remove() );
// Add click-handler to the button.
const setupButtonEvents = ( id ) => {
document