Use hosted fields button wrapper instead of checkout form to add the attribute

This commit is contained in:
dinamiko 2022-02-21 17:11:56 +01:00
parent ef99e53d6a
commit 635838c636

View file

@ -9,7 +9,6 @@ class CreditCardRenderer {
this.cardValid = false; this.cardValid = false;
this.formValid = false; this.formValid = false;
this.currentHostedFieldsInstance = null; this.currentHostedFieldsInstance = null;
this.formSubmissionSubscribed = false;
} }
render(wrapper, contextConfig) { render(wrapper, contextConfig) {
@ -122,8 +121,7 @@ class CreditCardRenderer {
}); });
const checkoutForm = document.forms.checkout; if (document.querySelector(wrapper).getAttribute('data-ppcp-subscribed') !== true) {
if(checkoutForm.getAttribute('data-ppcp-subscribed') !== true) {
document.querySelector(wrapper + ' button').addEventListener( document.querySelector(wrapper + ' button').addEventListener(
'click', 'click',
event => { event => {
@ -132,7 +130,7 @@ class CreditCardRenderer {
} }
); );
checkoutForm.setAttribute('data-ppcp-subscribed', true); document.querySelector(wrapper).setAttribute('data-ppcp-subscribed', true);
} }
}); });