Skip to content

Commit

Permalink
Fix spacing when switching ApplePay payment method in checkout page.
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrosilva-pt committed Dec 21, 2023
1 parent 425b7b4 commit db997e9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions modules/ppcp-applepay/resources/js/ApplepayButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class ApplepayButton {
// Stores initialization data sent to the button.
this.initialPaymentRequest = null;

// Default eligibility status.
this.isEligible = true;

this.log = function() {
if ( this.buttonConfig.is_debug ) {
console.log('[ApplePayButton]', ...arguments);
Expand Down Expand Up @@ -63,9 +66,9 @@ class ApplepayButton {
this.initEventHandlers();
this.isInitialized = true;
this.applePayConfig = config;
const isEligible = (this.applePayConfig.isEligible && window.ApplePaySession) || this.buttonConfig.is_admin;
this.isEligible = (this.applePayConfig.isEligible && window.ApplePaySession) || this.buttonConfig.is_admin;

if (isEligible) {
if (this.isEligible) {
this.fetchTransactionInfo().then(() => {
const isSubscriptionProduct = this.ppcpConfig?.data_client_id?.has_subscriptions === true;
if (isSubscriptionProduct) {
Expand Down Expand Up @@ -143,6 +146,11 @@ class ApplepayButton {
}

jQuery(document).on('ppcp-shown ppcp-hidden ppcp-enabled ppcp-disabled', (ev, data) => {
if (!this.isEligible) {
setVisible(wrapper_id, false);
return;
}

if (jQuery(data.selector).is(ppcpButtonWrapper)) {
syncButtonVisibility();
}
Expand Down

0 comments on commit db997e9

Please sign in to comment.