From 9ab11b40e4410b3f151cf989f0abfe2cfc867035 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Mon, 16 Oct 2023 17:56:58 +0100 Subject: [PATCH] Fix GooglePay preview buttons --- modules/ppcp-googlepay/resources/js/boot-admin.js | 11 +++++++++++ .../ppcp-googlepay/src/Helper/AvailabilityNotice.php | 7 +++++-- modules/ppcp-onboarding/resources/js/settings.js | 10 ++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/modules/ppcp-googlepay/resources/js/boot-admin.js b/modules/ppcp-googlepay/resources/js/boot-admin.js index 4cb606559..577733b6b 100644 --- a/modules/ppcp-googlepay/resources/js/boot-admin.js +++ b/modules/ppcp-googlepay/resources/js/boot-admin.js @@ -36,6 +36,17 @@ import widgetBuilder from "../../../ppcp-button/resources/js/modules/Renderer/Wi } }); + // Maybe we can find a more elegant reload method when transitioning from styling modes. + jQuery([ + '#ppcp-smart_button_enable_styling_per_location' + ].join(',')).on('change', () => { + setTimeout(() => { + for (const [selector, ppcpConfig] of Object.entries(activeButtons)) { + createButton(ppcpConfig); + } + }, 100); + }); + const applyConfigOptions = function (buttonConfig) { buttonConfig.button = buttonConfig.button || {}; buttonConfig.button.style = buttonConfig.button.style || {}; diff --git a/modules/ppcp-googlepay/src/Helper/AvailabilityNotice.php b/modules/ppcp-googlepay/src/Helper/AvailabilityNotice.php index d865094c1..9cadbc91a 100644 --- a/modules/ppcp-googlepay/src/Helper/AvailabilityNotice.php +++ b/modules/ppcp-googlepay/src/Helper/AvailabilityNotice.php @@ -109,10 +109,13 @@ class AvailabilityNotice { static function ( $notices ): array { $message = sprintf( + // translators: %1$s and %2$s are the opening and closing of HTML tag. __( - '

Notice: We could not determine your PayPal seller status to list your available features. Disconnect and reconnect your PayPal account through our onboarding process to resolve this.

Don\'t worry if you cannot use the onboarding process; most functionalities available to your account should work.

', + '

Notice: We could not determine your PayPal seller status to list your available features. Disconnect and reconnect your PayPal account through our %1$sonboarding process%2$s to resolve this.

Don\'t worry if you cannot use the %1$sonboarding process%2$s; most functionalities available to your account should work.

', 'woocommerce-paypal-payments' - ) + ), + '
', + '' ); // Name the key so it can be overridden in other modules. diff --git a/modules/ppcp-onboarding/resources/js/settings.js b/modules/ppcp-onboarding/resources/js/settings.js index 44fa692ed..f05f11ed3 100644 --- a/modules/ppcp-onboarding/resources/js/settings.js +++ b/modules/ppcp-onboarding/resources/js/settings.js @@ -19,7 +19,10 @@ document.addEventListener( if (! toggleElement.checked) { group.forEach( (elementToHide) => { - document.querySelector(elementToHide).style.display = 'none'; + const element = document.querySelector(elementToHide); + if (element) { + element.style.display = 'none'; + } }) } toggleElement.addEventListener( @@ -27,7 +30,10 @@ document.addEventListener( (event) => { if (! event.target.checked) { group.forEach( (elementToHide) => { - document.querySelector(elementToHide).style.display = 'none'; + const element = document.querySelector(elementToHide); + if (element) { + element.style.display = 'none'; + } }); return;