Check if the buttons are there before rendering it

In some cases WC replaces the checkout form only partially leaving the buttons there
This commit is contained in:
Mészáros Róbert 2020-04-09 12:57:21 +03:00
parent d31987ed46
commit fe2d7d170f

View file

@ -1,10 +1,18 @@
class Renderer {
render(wrapper, buttonConfig) {
if (this.isAlreadyRendered(wrapper)) {
return;
}
paypal.Buttons(
buttonConfig,
).render(wrapper);
}
isAlreadyRendered(wrapper) {
return document.querySelector(wrapper).hasChildNodes();
}
hideButtons(element) {
document.querySelector(element).style.display = 'none';
}