Woocommerce checkout page error messages image
Currently woocommerce showing error as above shown in image. I want individual error message below each input box as shown in below image. Please help.
Woocommerce checkout page error messages image
Currently woocommerce showing error as above shown in image. I want individual error message below each input box as shown in below image. Please help.
You need to add PHP snippet and css.
add_filter( 'woocommerce_form_field', 'checkout_fields_in_label_error', 10, 4 );
function checkout_fields_in_label_error( $field, $key, $args, $value ) {
if ( strpos( $field, '</span>' ) !== false && $args['required'] ) {
$error = '<span class="error" style="display:none">';
$error .= sprintf( __( '%s is a required field.', 'woocommerce' ), $args['label'] );
$error .= '</span>';
$field = substr_replace( $field, $error, strpos( $field, '</span>' ), 0);
}
return $field;
}
CSS:
.woocommerce-checkout p.woocommerce-invalid-required-field span.error {
color: #e2401c;
display: block !important;
font-weight: bold;
}