Woocommerce checkout page shows individual error if the required fields are empty. Normally, if all fields are empty, all errors for those empty fields will be shown:
- First name is a required field
- Last name is a required field
- Street address is a required field
- Town / City is a required field
and so on…
Is it possible to show only one error if all the required fields are empty? Like “ERROR: All fields are empty. Please fill in all required fields to place order.” How to achieve this?
Checkout page
You would need to disable the current error checking and write custom javascript for the checkout page that would put all the errors in a single message.
There's no native WooCommerce functionality that would accomplish this.
To remove validation, go to your checkout.php template and remove the
required
attribute from the html fields.Checkout this link on how to add HTML and javascript to the checkout page.
hHi, you can remove validation from checkout fields and add yours:
Here is the hook:
for more, you can go to
To set a unique validation error notice in Woocommerce checkout page you will use the following: (code is mainly from your last question and useful to the community. Just changed to the official function arguments code)
Code goes in function.php file of your active child theme (active theme). Tested and works.
Related: Set a unique validation error notice in Woocommerce My Account Addresses and Account Details
Its normally show when you press the checkout button. but if you watch it when page load. then maybe it's come by woocommerce bugs. you should update woocommerce plugin. I hope this error would be gone when you will update the plugin.
But after that, if you are facing the same issue contact me. I will look at it.
thank you