Do the classic checkout OSA bindings only on the classic page

Call `previousInitCheckout` only if there is one.
This commit is contained in:
Tomek Wytrębowicz 2023-11-23 16:51:22 +01:00 committed by Justin Palmer
parent cb4dd6e592
commit 6704a6426b
No known key found for this signature in database
GPG Key ID: ACAB7C35AA2577AF
1 changed files with 8 additions and 6 deletions

View File

@ -64,13 +64,15 @@
};
/**
* Add source values to checkout.
* Add source values to the classic checkout.
*/
const previousInitCheckout = document.body.oninit_checkout;
document.body.oninit_checkout = () => {
setFields();
previousInitCheckout();
};
if ( $( '.woocommerce form.checkout' ) !== null ) {
const previousInitCheckout = document.body.oninit_checkout;
document.body.oninit_checkout = () => {
setFields();
previousInitCheckout && previousInitCheckout();
};
}
/**
* Add source values to register.