diff --git a/modules/ppcp-button/resources/js/button.js b/modules/ppcp-button/resources/js/button.js index c84825fd6..8b63b26bb 100644 --- a/modules/ppcp-button/resources/js/button.js +++ b/modules/ppcp-button/resources/js/button.js @@ -148,7 +148,13 @@ const bootstrap = () => { miniCartBootstrap.init(); } - if (context === 'product' && PayPalCommerceGateway.single_product_buttons_enabled === '1') { + if ( + context === 'product' + && ( + PayPalCommerceGateway.single_product_buttons_enabled === '1' + || hasMessages() + ) + ) { const singleProductBootstrap = new SingleProductBootstap( PayPalCommerceGateway, renderer, @@ -194,6 +200,12 @@ const bootstrap = () => { } }; + +const hasMessages = () => { + return PayPalCommerceGateway.messages.is_hidden === false + && document.querySelector(PayPalCommerceGateway.messages.wrapper); +} + document.addEventListener( 'DOMContentLoaded', () => { diff --git a/modules/ppcp-button/resources/js/modules/ContextBootstrap/SingleProductBootstap.js b/modules/ppcp-button/resources/js/modules/ContextBootstrap/SingleProductBootstap.js index 484673d71..c2a622bff 100644 --- a/modules/ppcp-button/resources/js/modules/ContextBootstrap/SingleProductBootstap.js +++ b/modules/ppcp-button/resources/js/modules/ContextBootstrap/SingleProductBootstap.js @@ -187,6 +187,10 @@ class SingleProductBootstap { this.messages.renderWithAmount(data.total); + if ( this.gateway.single_product_buttons_enabled !== '1' ) { + return; + } + let enableFunding = this.gateway.url_params['enable-funding']; let disableFunding = this.gateway.url_params['disable-funding'];