Today I was dealing with a “little but annoying” thing. I found that there is an autofocus function on the First Name field under WooCommerce billing and shipping address. In a normal condition, maybe it’s not a problem. But when you did a customisation, for example : Re-order the fields, add some custom fields on the top and put the First Name to the middle or to the bottom, it doesn’t make sense to have the autofocus active.
As usual, I went to Uncle Google and found some threads. I found this and this. But unfortunately, all of those solutions are didn’t work for me. I guess because both of them are using
woocommerce_checkout_fields hook to call their function.
Finally, I wrote this code and it works:
Basically, by default WooCommerce will set an autofocus on the billing first name and shipping first name field. If you want to disable this, you need to set the autofocus into false and put it under
If you have any question or feedback, do not hesitate to leave your comment on the form below. 🙂