diff --git a/modules/ppcp-button/resources/js/modules/Renderer/PaymentButton.js b/modules/ppcp-button/resources/js/modules/Renderer/PaymentButton.js index ae2e5f668..071fe010d 100644 --- a/modules/ppcp-button/resources/js/modules/Renderer/PaymentButton.js +++ b/modules/ppcp-button/resources/js/modules/Renderer/PaymentButton.js @@ -659,8 +659,7 @@ export default class PaymentButton { const wrapper = this.wrapperElement; if ( this.#button ) { - this.log( 'addButton.removePrevious', this.#button ); - wrapper.removeChild( this.#button ); + this.removeButton(); } this.#button = button; @@ -671,17 +670,18 @@ export default class PaymentButton { * Removes the payment button from the DOM. */ removeButton() { - if ( ! this.isPresent ) { + if ( ! this.isPresent || ! this.#button ) { return; } this.log( 'removeButton' ); - if ( this.#button ) { - const wrapper = this.wrapperElement; - wrapper.removeChild( this.#button ); - - this.#button = null; + try { + this.wrapperElement.removeChild( this.#button ); + } catch ( Exception ) { + // Ignore this. } + + this.#button = null; } } diff --git a/modules/ppcp-googlepay/resources/js/GooglepayButton.js b/modules/ppcp-googlepay/resources/js/GooglepayButton.js index 2944ea12b..479f855db 100644 --- a/modules/ppcp-googlepay/resources/js/GooglepayButton.js +++ b/modules/ppcp-googlepay/resources/js/GooglepayButton.js @@ -70,7 +70,7 @@ class GooglepayButton extends PaymentButton { buttonConfig.button.wrapper, buttonConfig.button.mini_cart_wrapper, ppcpConfig.button.wrapper, - 'express-payment-method-ppcp-googlepay', + 'ppc-button-googlepay-container', 'ppc-button-ppcp-googlepay' ); }