Prevent PayPal subscription buttons to be rendered multiple times

This commit is contained in:
Emili Castells Guasch 2023-08-08 12:10:31 +02:00
parent be8015b8dd
commit 02e35bbe9d

View file

@ -22,6 +22,8 @@ class SingleProductBootstap {
this.renderer.onButtonsInit(this.gateway.button.wrapper, () => {
this.handleChange();
}, true);
this.subscriptionButtonsLoaded = false
}
form() {
@ -29,6 +31,8 @@ class SingleProductBootstap {
}
handleChange() {
this.subscriptionButtonsLoaded = false
if (!this.shouldRender()) {
this.renderer.disableSmartButtons(this.gateway.button.wrapper);
hide(this.gateway.button.wrapper, this.formSelector);
@ -187,6 +191,7 @@ class SingleProductBootstap {
return;
}
if(this.subscriptionButtonsLoaded) return
loadPaypalJsScript(
{
clientId: PayPalCommerceGateway.client_id,
@ -197,6 +202,8 @@ class SingleProductBootstap {
actionHandler.subscriptionsConfiguration(subscription_plan),
this.gateway.button.wrapper
);
this.subscriptionButtonsLoaded = true
return;
}