Although UX and accessibility experts won’t like this customization, it’s still important to know “what’s possible” with WooCommerce.
In regard to the checkout form (billing + shipping + notes), there is a useful “woocommerce_checkout_fields” hook (filter) that is widely used by developers like me to alter the behavior of input fields.
In today’s episode we will take a look, indeed, at how to remove the checkout field labels from their default position (above fields), and use them as placeholders instead, so that we save up some vertical space.
Enjoy!
Once the snippet below is active, your WooCommerce checkout fields will look like this; field labels will now display inside their respective input fields.
Please let me know in the comments if everything went as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting.
If you think this code saved you time & money, feel free to join 17,000+ WooCommerce Weekly subscribers for blog post updates and 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance!
Need Help with WooCommerce?
Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!
Rodolfo Melogli
Business Bloomer Founder
Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.
Hi Gregory, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Possible to notify user if a field is required of not? As it looks like now it not very good UX. User do not know what fields are required and what are optional
I actually had the same question coming here. The missing fields are marked red if the user tries to checkout but he has no way of knowing in advance, which fields are considered required.
I am guessing Ryan Logan had the same question/issue above.
It seems to be a question of either having everything inline but no required field indicator or keeping everything as is to keep he asterisks. Is there any way out of this dilemma?
Hey Michael, I take the placeholder could take an “*” if the field is required, or you could style field borders via CSS. I’m afraid this is custom work – if you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hello all,
For me, the following solution worked well. It adds an asterix for required fields and (optional) for not-required fields. You can change it to whatever you need in the code. Hope it works for you too.
Questions? Feedback? Support? Leave your Comment Now! _____
If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)
With 100,000 (and growing) monthly organic sessions, Business Bloomer is the most consistent, most active and most complete WooCommerce development/customization blog.
Of course this website itself uses the WooCommerce plugin, the Storefront theme and runs on a WooCommerce-friendly hosting.
Hello,
Could you show us how to edit the code so that we can assign this to specific fields, rather than all fields?
Hi Gregory, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Awesome stuff! Now, if we can only get the asterisk to remain for required fields. ; )
๐
Hello,
Possible to notify user if a field is required of not? As it looks like now it not very good UX. User do not know what fields are required and what are optional
WooCommerce should already change the border to red for required fields, can you see that? Let me know
I actually had the same question coming here. The missing fields are marked red if the user tries to checkout but he has no way of knowing in advance, which fields are considered required.
I am guessing Ryan Logan had the same question/issue above.
It seems to be a question of either having everything inline but no required field indicator or keeping everything as is to keep he asterisks. Is there any way out of this dilemma?
Hey Michael, I take the placeholder could take an “*” if the field is required, or you could style field borders via CSS. I’m afraid this is custom work – if you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hello all,
For me, the following solution worked well. It adds an asterix for required fields and (optional) for not-required fields. You can change it to whatever you need in the code. Hope it works for you too.
Thanks!