WooCommerce : Show Only One Error Message on Checkout Field Error.

Code

How to Show Only One Error Message For WooCommerce Checkout Field?

Their are approximately 7 to 10 default field which are required on WooCommerce checkout field.
In case these all have error then their are so much error in top, you can see in screenshot below. so for removing or we can say replacing all error with only one msg , you can view in screenshot 2.

null

Example :

function ShowOneError( $fields, $errors ){
  // if their is any validation errors
  if( !empty( $errors->get_error_codes() ) ) {
    // remove all of Error msg
    foreach( $errors->get_error_codes() as $code ) {
      $errors->remove( $code );
    }
  // our custom Error msg
  $errors->add('validation','There is an error in filed data.');
  } 
}
add_action('woocommerce_after_checkout_validation','ShowOneError',999,2);
null

Please note, that above code removes all types of errors, not only “This Field Is Required” etc.
We can remove them conditionally . For this first we need to type of error.
Types of errors:

  • required-field
  • terms (Terms checkbox)
  • payment

So for removing Only “required-field” error:

function ShowOneError( $fields, $errors ){
  // if their is any validation errors
  if( !empty( $errors->get_error_codes() ) ) {
    // remove all of Error msg
    foreach( $errors->get_error_codes() as $code ) {
     if( $code == 'required-field') {
      $errors->remove( $code );
     }
    }
  // our custom Error msg
  $errors->add('validation','There is an error in filed data.');
  } 
}
add_action('woocommerce_after_checkout_validation','ShowOneError',999,2);

Related reading:

Shiv Kumawat

Executive Director & CEO

Shiv Kumawat is the CEO of Eoxys IT Solution LLP, a Jaipur-based IT and GenAI development company he has led since 2009. Eoxys has delivered 700+ projects, building custom AI agents, chatbots, mobile apps and web platforms for businesses worldwide. Shiv writes about practical AI app development and what it takes to ship software that works.

Latest Posts

Isometric illustration of a business hiring a remote AI development team in India, with a laptop showing an AI chip linked across a globe to developer workstations

Hire AI Developers in India: Models, Vetting and Red Flags

If you plan to hire AI developers in India, the hard part is not finding people. It is telling a…

Shiv Kumawat
October 11, 2026
DPDP compliance for AI apps: isometric shield protecting a phone and cloud server, with consent toggle, padlock and data cubes on a navy background

DPDP Compliance for AI Apps: What to Fix Before May 2027

If your app or AI chatbot handles personal data of people in India, DPDP compliance for AI apps is now…

Shiv Kumawat
October 10, 2026
GPT-6.1 Sol vs Claude Sonnet 5.5: isometric illustration of two AI model cubes connected by a data stream on a navy background

GPT-6.1 Sol vs Claude Sonnet 5.5: Which Model for Your App?

GPT-6.1 Sol vs Claude Sonnet 5.5 is the mid-tier choice most founders are making right now. Both models launched in…

Shiv Kumawat
October 9, 2026
,

Leave a Reply

Your email address will not be published. Required fields are marked *