title: Custom checkout fields validation in Woocommerce 3
body: <p>I've created custom input fields on the checkout page for a bookings website. The amount of input fields is based on the person count. I've managed to get them displayed on the checkout form, getting them sanitized and being displayed in de order admin panel. The input fields are required, so an error (wc_add_notice) should appear if one of more of the fields are empty. How can I achieve to get te wc_add_notice? Here is my code:</p>
  
  <pre><code>//* Add a new checkout field 
  function ppp_filter_checkout_fields($fields){
      $fields['extra_fields'] = array(
      'participant_details' =&gt; array(
          'type' =&gt; 'participant_details',
          'required'      =&gt; true,
          'label' =&gt; __( 'Participant Details' )
          ),
      );
  
      return $fields;
  
  }
  add_filter( 'woocommerce_checkout_fields', 'ppp_filter_checkout_fields' );
  
  //* Add the field to the checkout
  function ppp_filter_checkout_field_group( $field, $key, $args, $value ){
      $op_cart_count = WC()-&gt;cart-&gt;get_cart_contents_count();
  
      $items = WC()-&gt;cart-&gt;get_cart();
  
      foreach($items as $item) { 
          $person = $item['booking']['_persons'][0];
      }
  
      if ($person &gt; 1) {
  
          $html = '';
  
          $html .= "&lt;h3&gt;Deelnemers&lt;/h3&gt;";
  
          for ( $i = 1; $i &lt; $person; $i++) {
              $counter = $i + 1;
  
              $html .= "Deelnemer ". $counter . "&lt;br&gt;";
  
              $html .= woocommerce_form_field( "participant_details[$i][full_name]", array(
                  "type" =&gt; "text",
                  "return" =&gt; true,
                  "value" =&gt; "",
                  "required"      =&gt; true,
                  "label" =&gt; __( "Naam" )
                  )
              );
              $html .= woocommerce_form_field( "participant_details[$i][email_address]", array(
                  "type" =&gt; "text",
                  "return" =&gt; true,
                  "value" =&gt; "",
                  "required"      =&gt; true,
                  "label" =&gt; __( "Emailadres" )
                  )
              );
  
          }
          return $html;
  
      }
  }
  add_filter( 'woocommerce_form_field_participant_details', 'ppp_filter_checkout_field_group', 10, 4 );
  
  //* display the extra field on the checkout form
  function ppp_extra_checkout_fields(){ 
  
      $checkout = WC()-&gt;checkout();
  
      foreach ( $checkout-&gt;checkout_fields['extra_fields'] as $key =&gt; $field ) :
  
          woocommerce_form_field( $key, $field, $checkout-&gt;get_value( $key ) );
  
      endforeach;
  
  
  }
  add_action( 'woocommerce_checkout_after_customer_details' ,'ppp_extra_checkout_fields' );
  
  //* Sanitize our custom field
  function ppp_custom_process_checkout_field_participant_details( $posted ){
  
      $clean = array();
  
      foreach( $posted as $participant ){
          $details = ppp_custom_checkout_clean_participant_details( $participant );
  
          if( ! empty( $details ) ){
              $clean[] = $details;
          }
      }
  
      return $clean;
  }
  add_filter( 'woocommerce_process_checkout_participant_details_field', 'ppp_custom_process_checkout_field_participant_details' );
  
  //*
  function ppp_custom_checkout_clean_participant_details( $participant = array() ){
      $details = array();
      if( isset( $participant["full_name"] ) ){
          $details['full_name'] = sanitize_text_field( $participant["full_name"] );
      }
      if( isset( $participant["email_address"] ) ){
          $details['email_address'] = sanitize_text_field( $participant["email_address"] );
      }
      return $details;
  }
  
  //* Update_post_meta
  function ppp_custom_checkout_field_update_order_meta( $order_id, $posted ){
  
      if( ! empty( $posted["participant_details"] ) ){
          update_post_meta( $order_id, "_participant_details", $posted["participant_details"] );
      } else {
          delete_post_meta( $order_id, "_participant_details" );
      }
  
  }
  add_action( 'woocommerce_checkout_update_order_meta', 'ppp_custom_checkout_field_update_order_meta', 10, 2 );
  
  //* Display the extra data in the order admin panel
  function ppp_display_order_data_in_admin( $order ){  
  
      $participant_details = get_post_meta( $order-&gt;id, "_participant_details", true ); 
  
      if( ! empty( $participant_details ) ) { 
  
          $participant_defaults = array(
                  "full_name" =&gt; "",
                  "email_address" =&gt; ""
              );
  
      ?&gt;
      &lt;div class="participant_data"&gt;
          &lt;h4&gt;&lt;?php _e( "Deelnemers Lijst", "prespersadprodukties" ); ?&gt;&lt;/h4&gt;
          &lt;?php 
              $i = 1;
  
              foreach( $participant_details as $participant ){
  
                  $participant = wp_parse_args( $participant, $participant_defaults );
  
                  echo "&lt;p&gt;&lt;strong&gt;" . sprintf( __( "Deelnemer %s", "prespersadprodukties" ), $i+1  ) . "&lt;/strong&gt;" . "&lt;br/&gt;";
                  echo __( "Naam", "prespersadprodukties" ) . ' : ' . $participant["full_name"] . "&lt;br/&gt;";
                  echo __( "Emailadres", "prespersadprodukties" ) . ' : ' . $participant["email_address"] . "&lt;br/&gt;";
                  echo "&lt;/p&gt;";
  
                  $i++;
  
              }
  
           ?&gt;
      &lt;/div&gt;
  &lt;?php }
  }
  add_action( 'woocommerce_admin_order_data_after_order_details', 'ppp_display_order_data_in_admin' );
  </code></pre>