Clean button wrapper content on each init

This commit is contained in:
Emili Castells Guasch 2023-12-14 15:40:28 +01:00
parent c3d0039f83
commit 4b536491f2

View file

@ -23,6 +23,11 @@ const init = () => {
setVisibleByClass(ORDER_BUTTON_SELECTOR, getCurrentPaymentMethod() !== PaymentMethods.PAYPAL, 'ppcp-hidden');
setVisible(`#ppc-button-${PaymentMethods.PAYPAL}-save-payment-method`, getCurrentPaymentMethod() === PaymentMethods.PAYPAL);
const buttonWrapper = document.querySelector(`#ppc-button-${PaymentMethods.PAYPAL}-save-payment-method`);
while (buttonWrapper.firstChild) {
buttonWrapper.removeChild(buttonWrapper.firstChild);
}
if(getCurrentPaymentMethod() === PaymentMethods.PAYPAL) {
loadPaypalJsScriptPromise({
clientId: ppcp_add_payment_method.client_id,