Created
May 26, 2025 08:45
-
-
Save shameemreza/2ec6ed20f114aabed5763d2ae900ea34 to your computer and use it in GitHub Desktop.
Fixes the issue where the Enter key doesn't submit the WooCommerce login form when user registration is disabled. Temporary workaround until WooCommerce 9.9.9 (June 2, 2025).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Fix for WooCommerce login form Enter key not working when registration is disabled | |
* This is a temporary fix until WooCommerce 9.9.9 is released (June 2, 2025) | |
*/ | |
function fix_woocommerce_login_enter_key() { | |
// Only add this script on pages that might have the login form | |
if (!is_account_page() && !is_checkout()) { | |
return; | |
} | |
wp_add_inline_script('woocommerce', ' | |
jQuery(function($) { | |
// Target all password inputs in login forms regardless of #customer_login existence | |
$(".woocommerce-form-login .password-input").on("keydown", function(event) { | |
if ("Enter" === event.key) { | |
$(this).closest("form").find("[type=submit]").click(); | |
} | |
}); | |
}); | |
'); | |
} | |
add_action('wp_enqueue_scripts', 'fix_woocommerce_login_enter_key', 99); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment