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, the Jaipur-based IT company he has led since 2009. An AI & IT Solutions Consultant with 16+ years of experience, he works with startups and enterprises to turn ideas into market-ready SaaS platforms, mobile apps and AI-driven solutions. His team has delivered 700+ projects across SaaS, mobile and web apps, automation and AI. He previously served as Chief Technology Officer for a US company.

Latest Posts

RAG chatbot architecture and guardrails banner with archive shelving representing a company knowledge base

RAG Chatbot Architecture and Guardrails: A Production Guide

A chatbot can quote a policy accurately and still give an unacceptable answer: the policy might be withdrawn, or belong…

Shafeeq Khan
November 20, 2026
Food delivery app development cost in the UAE 2026 banner with a delivery rider and scooter

Food Delivery App Development Cost in the UAE (2026)

A food delivery order in the UAE only works if four things line up: the right kitchen accepts it, the…

Shafeeq Khan
November 20, 2026
Colour photograph illustrating the Eoxys blog post 'Hire an AI Governance Engineer: Skills, Laws and When to Hire', used as the featured image for hire ai governance engineer.

Hire an AI Governance Engineer: Skills, Laws and When to Hire

Two years ago most companies building with AI had no one whose job was to ask “what happens when this…

Shafeeq Khan
November 20, 2026
,

Leave a Reply

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