Fix in the Single Product load SingleProductBootstap when we have Messages even if buttons are not present

This commit is contained in:
Pedro Silva 2023-08-09 15:03:54 +01:00
parent 02de8ada7f
commit 89288603c3
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
2 changed files with 17 additions and 1 deletions

View file

@ -148,7 +148,13 @@ const bootstrap = () => {
miniCartBootstrap.init(); 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( const singleProductBootstrap = new SingleProductBootstap(
PayPalCommerceGateway, PayPalCommerceGateway,
renderer, renderer,
@ -194,6 +200,12 @@ const bootstrap = () => {
} }
}; };
const hasMessages = () => {
return PayPalCommerceGateway.messages.is_hidden === false
&& document.querySelector(PayPalCommerceGateway.messages.wrapper);
}
document.addEventListener( document.addEventListener(
'DOMContentLoaded', 'DOMContentLoaded',
() => { () => {

View file

@ -187,6 +187,10 @@ class SingleProductBootstap {
this.messages.renderWithAmount(data.total); this.messages.renderWithAmount(data.total);
if ( this.gateway.single_product_buttons_enabled !== '1' ) {
return;
}
let enableFunding = this.gateway.url_params['enable-funding']; let enableFunding = this.gateway.url_params['enable-funding'];
let disableFunding = this.gateway.url_params['disable-funding']; let disableFunding = this.gateway.url_params['disable-funding'];