How to translate Woocommerce Checkout page validation error messages? I have tried to used
function ship_to_different_address_translation( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Billing First name is a required field.' :
if ( get_locale() == 'en_GB' ) {
$translated_text = __( 'Please fill in all the required fields!', 'woocommerce' );
}
break;
}
return $translated_text;
}
add_filter('gettext', 'ship_to_different_address_translation', 20, 3);
This code works for all the strings (except checkout validation error messages). Is it possible to replace all the error messages with 'Please fill in all the required fields!'?

1) Customizing default validation error notices for Woocommerce checkout fields:
You can use woocommerce_checkout_required_field_notice dedicated filter hook, to customize each notice, changing the text below:
add_filter( 'woocommerce_checkout_required_field_notice', 'custom_checkout_required_fields_error_notice', 10, 2 );
function custom_checkout_required_fields_error_notice( $error_notice, $field_label ) {
$error_notice = sprintf( __( '%s is a required field.', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>' );
return $error_notice;
}
Code goes in function.php file of your active child theme (active theme). Tested and works.
2) Replace all validation errors notice with a one unique custom error notice for Woocommerce checkout fields:
See: Set a unique validation error notice in Woocommerce checkout page
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With