From 40688b706f12e40bfd21cdaf8cea9d25c6193128 Mon Sep 17 00:00:00 2001
From: Philipp Stracker
Date: Wed, 30 Oct 2024 12:17:41 +0100
Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20FIx=20the=20button=20preview=20i?=
=?UTF-8?q?n=20admin=20settings?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../js/Preview/ApplePayPreviewButton.js | 23 +++++++++++++------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/modules/ppcp-applepay/resources/js/Preview/ApplePayPreviewButton.js b/modules/ppcp-applepay/resources/js/Preview/ApplePayPreviewButton.js
index 2ad3e23f5..69ba86f1c 100644
--- a/modules/ppcp-applepay/resources/js/Preview/ApplePayPreviewButton.js
+++ b/modules/ppcp-applepay/resources/js/Preview/ApplePayPreviewButton.js
@@ -5,6 +5,11 @@ import PreviewButton from '../../../../ppcp-button/resources/js/modules/Preview/
* A single Apple Pay preview button instance.
*/
export default class ApplePayPreviewButton extends PreviewButton {
+ /**
+ * @type {?PaymentButton}
+ */
+ #button = null;
+
constructor( args ) {
super( args );
@@ -19,14 +24,18 @@ export default class ApplePayPreviewButton extends PreviewButton {
}
createButton( buttonConfig ) {
- const button = new ApplepayButton(
- 'preview',
- null,
- buttonConfig,
- this.ppcpConfig
- );
+ if ( ! this.#button ) {
+ this.#button = new ApplepayButton(
+ 'preview',
+ null,
+ buttonConfig,
+ this.ppcpConfig
+ );
+ }
- button.init( this.apiConfig );
+ this.#button.configure( this.apiConfig, null );
+ this.#button.applyButtonStyles( buttonConfig, this.ppcpConfig );
+ this.#button.reinit();
}
/**