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

Code

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

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);

Shiv kumawat

Executive Director & CEO

"Shiv kumawat is the Executive Director and CEO of Eoxys It Solution LLP and the strategic mind behind the company"s growth. His expertise in operational efficiency and team leadership empowers his colleagues to excel and innovate.”

Latest Posts

Generative AR Shopping Apps 2026 67% Conversion Boost

  AI Agent Mobile Apps 2026 $2.3M ARR in 90 Days (Complete Guide) The 73% Cart Abandonment Problem You’re Solving…

Shafeeq Khan
January 31, 2026

AI Agent Mobile Apps 2026 $2.3M ARR in 90 Days (Complete Guide)

  AI Agent Mobile Apps 2026 $2.3M ARR in 90 Days (Complete Guide) The $2.3M ARR Problem You’re Solving  …

Shafeeq Khan
January 30, 2026

Top 12 AI App Development Trends 2026 Build $10M ARR Apps Agencies Are Charging $500K To Create

  Top 12 AI App Development Trends 2026 Build $10M ARR Apps Agencies Are Charging $500K To Create Trend #1…

Shafeeq Khan
January 26, 2026
, ,

Leave a Reply

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