Display payment gateways also when the are set to display:none with css and the stylesheet is removed from DOM

This commit is contained in:
Daniel Hüsken 2024-10-17 14:18:19 +02:00
parent bbd25f89e8
commit a453e4e881
No known key found for this signature in database
GPG key ID: 9F732DA37FA709E8
5 changed files with 28 additions and 0 deletions

View file

@ -407,6 +407,11 @@ class ApplePayButton {
.querySelectorAll( 'style#ppcp-hide-apple-pay' )
.forEach( ( el ) => el.remove() );
const paymentMethodAppleLi = document.querySelector('.wc_payment_method.payment_method_ppcp-applepay' );
if (paymentMethodAppleLi.style.display === 'none' || paymentMethodAppleLi.style.display === '') {
paymentMethodAppleLi.style.display = 'block';
}
this.allElements.forEach( ( element ) => {
element.style.display = '';
} );

View file

@ -38,6 +38,12 @@ class CardFieldsFreeTrialRenderer {
if ( hideDccGateway ) {
hideDccGateway.parentNode.removeChild( hideDccGateway );
}
const dccGatewayLi = document.querySelector(
'.wc_payment_method.payment_method_ppcp-credit-card-gateway'
);
if (dccGatewayLi.style.display === 'none' || dccGatewayLi.style.display === '') {
dccGatewayLi.style.display = 'block';
}
this.errorHandler.clear();

View file

@ -44,6 +44,12 @@ class CardFieldsRenderer {
if ( hideDccGateway ) {
hideDccGateway.parentNode.removeChild( hideDccGateway );
}
const dccGatewayLi = document.querySelector(
'.wc_payment_method.payment_method_ppcp-credit-card-gateway'
);
if (dccGatewayLi.style.display === 'none' || dccGatewayLi.style.display === '') {
dccGatewayLi.style.display = 'block';
}
const cardFields = paypal.CardFields( {
createOrder: contextConfig.createOrder,

View file

@ -52,6 +52,12 @@ class HostedFieldsRenderer {
if ( hideDccGateway ) {
hideDccGateway.parentNode.removeChild( hideDccGateway );
}
const dccGatewayLi = document.querySelector(
'.wc_payment_method.payment_method_ppcp-credit-card-gateway'
);
if (dccGatewayLi.style.display === 'none' || dccGatewayLi.style.display === '') {
dccGatewayLi.style.display = 'block';
}
const cardNumberField = document.querySelector(
'#ppcp-credit-card-gateway-card-number'

View file

@ -763,11 +763,16 @@ export default class PaymentButton {
const styleSelector = `style[data-hide-gateway="${ this.methodId }"]`;
const wrapperSelector = `#${ this.wrappers.Default }`;
const paymentMethodLi = document.querySelector(`.wc_payment_method.payment_method_${ this.methodId }`);
document
.querySelectorAll( styleSelector )
.forEach( ( el ) => el.remove() );
if (paymentMethodLi.style.display === 'none' || paymentMethodLi.style.display === '') {
paymentMethodLi.style.display = 'block';
}
document
.querySelectorAll( wrapperSelector )
.forEach( ( el ) => el.remove() );