Woocommerce自定义结帐需要现场行为问题

I copied some code into my functions.php file to include a NIF / CIF field in the checkout page. It had to be a required and that worked just fine, but for some reason it has stopped working and now a customer can checkout without entering anything into the field.

function woo_custom_field_checkout($checkout) {
  echo '<div id="additional_checkout_field">';
  woocommerce_form_field( 'nif', array( // Identificador del campo 
    'type'          => 'text',
    'class'         => array('my-field-class form-row-wide'),
    'required'      => true,            // ¿El campo es obligatorio 'true' o 'false'?
    'label'       => __('NIF / CIF'),   // Nombre del campo 
    'placeholder'   => __('Ej: 12345678X'), // Texto de apoyo que se muestra dentro del campo
  ), $checkout->get_value( 'nif' ));    // Identificador del campo 
  echo '</div>'; 
}
add_action( 'woocommerce_after_checkout_billing_form', 'woo_custom_field_checkout' );

/*
* INCLUYE NIF/CIF EN LOS DETALLES DEL PEDIDO CON EL NUEVO CAMPO
*/
function woo_custom_field_checkout_update_order($order_id) {
  if ( ! empty( $_POST['nif'] ) ) {
    update_post_meta( $order_id, 'NIF', sanitize_text_field( $_POST['nif'] ) );
  }
}
add_action( 'woocommerce_checkout_update_order_meta', 'woo_custom_field_checkout_update_order' );
/*
* MUESTRA EL VALOR DEL CAMPO NIF/CIF LA PÁGINA DE MODIFICACIÓN DEL PEDIDO
*/
function woo_custom_field_checkout_edit_order($order){
  echo '<p><strong>'.__('NIF').':</strong> ' . get_post_meta( $order->id, 'NIF', true ) . '</p>';
}
add_action( 'woocommerce_admin_order_data_after_billing_address', 'woo_custom_field_checkout_edit_order', 10, 1 );
/*
* INCLUYE EL CAMPO NIF/CIF EN EL CORREO ELECTRÓNICO DE AVISO A TU CLIENTE
*/
function woo_custom_field_checkout_email($keys) {
  $keys[] = 'NIF';
  return $keys;
}
add_filter('woocommerce_email_order_meta_keys', 'woo_custom_field_checkout_email');

The missing code is the following, that will output a error notice if the field is empty:

// VALIDA EL CAMPO CUANDO SE PUBLIQUE EL FORMULARIO DE PAGO
add_action('woocommerce_checkout_process', 'custom_checkout_field_process');
function custom_checkout_field_process() {
    // Check if set, if its not set add an error.
    if ( ! $_POST['nif'] )
        wc_add_notice( __( 'Por favor, ingrese el campo NIF/CIF.' ), 'error' );
}

Code goes in function.php file of your active child theme (or active theme).

Tested and works. If the field is not filled, when submitted customer will get this notice:

enter image description here