From 2fa5545af2d1e7e8742bee3448567ea37f31d48f Mon Sep 17 00:00:00 2001 From: Philipp Stracker Date: Wed, 28 Aug 2024 15:54:41 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20FIx=20potential=20problem=20with?= =?UTF-8?q?=20initialization=20order?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/js/modules/Renderer/PaymentButton.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/ppcp-button/resources/js/modules/Renderer/PaymentButton.js b/modules/ppcp-button/resources/js/modules/Renderer/PaymentButton.js index 154c3328c..a54f5ebb6 100644 --- a/modules/ppcp-button/resources/js/modules/Renderer/PaymentButton.js +++ b/modules/ppcp-button/resources/js/modules/Renderer/PaymentButton.js @@ -732,12 +732,11 @@ export default class PaymentButton { * Only relevant on the checkout page, i.e., when `this.isSeparateGateway` is `true` */ showPaymentGateway() { - if ( this.#gatewayInitialized ) { - return; - } - this.#gatewayInitialized = true; - - if ( ! this.isSeparateGateway || ! this.isEligible ) { + if ( + this.#gatewayInitialized || + ! this.isSeparateGateway || + ! this.isEligible + ) { return; } @@ -753,6 +752,7 @@ export default class PaymentButton { .forEach( ( el ) => el.remove() ); this.log( 'Show gateway' ); + this.#gatewayInitialized = true; // This code runs only once, during button initialization, and fixes the initial visibility. this.isVisible = this.isCurrentGateway;