** Add Inline Field Error Notifications WooCommerce Checkout */ add_filter( 'woocommerce_form_field', 'bbloomer_checkout_fields_in_label_error', 10, 4 ); function bbloomer_checkout_fields_in_label_error( $field, $key, $args, $value ) { if ( strpos( $field, '</label>' ) !== 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, '</label>' ), 0); } return $field; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter