Skip to content

Commit

Permalink
Merge pull request #2705 from woocommerce/PCP-2170_Fix_probs_with_aut…
Browse files Browse the repository at this point in the history
…ooptimize

Fix problems with autoptimize plugin (2170)
  • Loading branch information
Dinamiko authored Oct 30, 2024
2 parents 99d4c15 + a453e4e commit c1ff263
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/ppcp-applepay/resources/js/ApplepayButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand Down

0 comments on commit c1ff263

Please sign in to comment.