title: Collect checked Checkboxes and save values in Woocommerce order meta
body: <p>I need kind of a seat reservation extension for woocommerce. Since most of the available plugins don't fit to well or don't work at all, i decided to try it myself.</p>
  
  <p><strong>Create the field (Product Meta) to store which seats are booked</strong></p>
  
  <pre><code>add_action( 'woocommerce_product_data_panels', 'srd_seats' );
  function srd_seats() {
      global $woocommerce, $post;
  
          ?&gt;&lt;div id="srd_seating_data" class="panel woocommerce_options_panel"&gt;&lt;?php
          woocommerce_wp_checkbox(
          array(
              'id'            =&gt; '_seat_1',
              'label'         =&gt; __('1', 'woocommerce' ),
              )
          );
              woocommerce_wp_checkbox(
          array(
              'id'            =&gt; '_seat_2',
              'label'         =&gt; __('2', 'woocommerce' ),
              )
          );
              woocommerce_wp_checkbox(
          array(
              'id'            =&gt; '_seat_3',
              'label'         =&gt; __('3', 'woocommerce' ),
              )
          );
              woocommerce_wp_checkbox(
          array(
              'id'            =&gt; '_seat_4',
              'label'         =&gt; __('4', 'woocommerce' ),
              )
          );
              woocommerce_wp_checkbox(
          array(
              'id'            =&gt; '_seat_5',
              'label'         =&gt; __('5', 'woocommerce' ),
              )
          );
  </code></pre>
  
  <p><strong>Saving the data</strong></p>
  
  <pre><code> add_action( 'woocommerce_process_product_meta', 'srd_seatings_save' );
  function srd_seatings_save( $post_id ){
  
      $woocommerce_checkbox = isset( $_POST['_seat_1'] ) ? 'yes' : 'no';
      update_post_meta( $post_id, '_seat_1', $woocommerce_checkbox );
      $woocommerce_checkbox = isset( $_POST['_seat_2'] ) ? 'yes' : 'no';
      update_post_meta( $post_id, '_seat_2', $woocommerce_checkbox );
      $woocommerce_checkbox = isset( $_POST['_seat_3'] ) ? 'yes' : 'no';
      update_post_meta( $post_id, '_seat_3', $woocommerce_checkbox );
      $woocommerce_checkbox = isset( $_POST['_seat_4'] ) ? 'yes' : 'no';
      update_post_meta( $post_id, '_seat_4', $woocommerce_checkbox );
      $woocommerce_checkbox = isset( $_POST['_seat_5'] ) ? 'yes' : 'no';
      update_post_meta( $post_id, '_seat_5', $woocommerce_checkbox );
  </code></pre>
  
  <p><strong>Output as checkboxes on checkout Page</strong>
  Output all values as checkboxes: Booked seats get a special treatment and are disabled.</p>
  
  <pre><code>add_action( 'woocommerce_before_order_notes' , 'srd_seat_reservation');
  
  function srd_seat_reservation($checkout){
  
      // Loop through cart item quantity
      foreach( WC()-&gt;cart-&gt;get_cart() as $cart_item ) {
  
          $seats = array( '_seat_1',
                          '_seat_2',
                          '_seat_3',
                          '_seat_4',
                          '_seat_5',
                              );
  
          foreach ($seats as $seat) {
          $seatnumber = preg_replace('/[^0-9.]+/', '', $seat);
          if ( get_post_meta( $cart_item[ 'product_id' ], $seat, true) == 'yes'){
              echo '&lt;input type="checkbox" disabled="disabled" checked="checked"&gt;'.$seatnumber.'&lt;br&gt;';}
              else {
              echo '&lt;input type="checkbox" name="checkboxseat[]" value="'.$seatnumber.'"&gt;'.$seatnumber.'&lt;br&gt;';
                          }
              }
      }
  }
  </code></pre>
  
  <p><strong>Validate the selected fields</strong>
  Customer needs to select exactly as many seats as there are items in cart. </p>
  
  <pre><code>    add_action('woocommerce_checkout_process', 'srd_seating_process');
  function srd_seating_process() {
          $quantity = WC()-&gt;cart-&gt;get_cart_contents_count(); // Get cart quantity
          $checked_arr = count($_POST['checkboxseat']); // Get Number of checked Checkboxes
  
          if ($quantity &gt; $checked_arr)
                  wc_add_notice( __( 'Bitte wählen Sie für jeden Teilnehmer einen Sitzplatz.', 'woocommerce' ), 'error' );
          if ($quantity &lt; $checked_arr)
                  wc_add_notice( __( 'Sie haben zu viele Sitzplätze ausgewählt.', 'woocommerce' ), 'error' );
  }
  </code></pre>
  
  <blockquote>
    <p><strong>My problem</strong> The next step would be to save the value ($seatnumber) of all selected checkboxes to the order meta and to update the product meta. I am struggeling to collect the selected checkboxes and save the values. Please see below my attempt of achieving it. Any help is highly appreciated! =)</p>
  </blockquote>
  
  <pre><code>add_action('woocommerce_checkout_create_order', 'srd_seating_create_order', 20, 2 );
  function srd_seating_create_order( $order, $data ) {
  
  
      foreach($_POST['checkboxseat'] as $check) {
                  $order-&gt;update_meta_data( 'Sitzplatz' , $check );
          }
  }
  </code></pre>