Check input exists

This commit is contained in:
Mike Jolley 2024-09-19 13:36:15 +01:00
parent 9b2bed5bbc
commit 391af06505
1 changed files with 5 additions and 1 deletions

View File

@ -365,7 +365,11 @@ class WC_Settings_Accounts extends WC_Settings_Page {
if ( guestCheckout ) {
guestCheckout.addEventListener('change', function() {
const isChecked = this.checked;
document.getElementById("woocommerce_enable_delayed_account_creation").disabled = !isChecked;
const input = document.getElementById("woocommerce_enable_delayed_account_creation");
if ( ! input ) {
return;
}
input.disabled = !isChecked;
});
guestCheckout.dispatchEvent(new Event('change')); // Initial state
}