title: WooCommerce functions for dropdown boxes
body: <p>I am not a wordpress developer and I am trying to piece in a small function on a woocommerce checkout function. What I need is two fold. The first is the ability to drop in a simple function that allows for a drop down box on the checkout page. I did manage to find this code:</p>
  
  <pre><code>add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
  
  function my_custom_checkout_field( $checkout ) {
  
  echo '&lt;div id="my_custom_checkout_field"&gt;&lt;h2&gt;'.__('Purchase Extra').'&lt;/h2&gt;';
  
  woocommerce_form_field( 'my_field_name', array(
      'type'          =&gt; 'text',
      'class'         =&gt; array('my-field-class form-row-wide'),
      'label'         =&gt; __('Fill in this field'),
      'placeholder'       =&gt; __('Enter something'),
      ), $checkout-&gt;get_value( 'my_field_name' ));
  
  echo '&lt;/div&gt;';
  
  }
  </code></pre>
  
  <p>And woocommerces docs say you can add the drop down like this:</p>
  
  <pre><code>$fields['billing']['your_field']['options'] = array(
         'option_1' =&gt; 'Option 1 text',
         'option_2' =&gt; 'Option 2 text'
    );
  </code></pre>
  
  <p>I do not know how to merge the two together.</p>
  
  <p>How to extract that selection after the checkout was successful?</p>
  
  <p>===========================================
  I've tried the new code and while everything seems
  to be working ok - the value of the selection isn't
  being saved to the database. It's just blank.</p>
  
  <p><strong>Here's my update code</strong></p>
  
  <pre><code> add_action('woocommerce_before_order_notes', 'my_custom_checkout_field');
  
   function my_custom_checkout_field( $checkout ) {
  
  echo '&lt;div id="my_custom_checkout_field"&gt;&lt;h2&gt;'.__('Purchase Domain').'&lt;/h2&gt;';
  
  woocommerce_form_field( 'do_domain', array(
      'type'          =&gt; 'select',
      'class'         =&gt; array('chzn-drop'),
      'label'         =&gt; __('Purchase from KitKamp?'),
      'placeholder'   =&gt; __('Enter something'),
      'options'       =&gt; array(
                      'subdomain' =&gt; __('No Thank You', 'woocommerce' ),
                      'domain' =&gt; __('Yes Please', 'woocommerce' )
                  )
      ), 
  
      $checkout-&gt;get_value( 'do_domain' ));
  
  echo '&lt;/div&gt;';
  
  }
  
  
   add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');
  
   function my_custom_checkout_field_process() {
      global $woocommerce;
  
      // Check if set, if its not set add an error.
      if (!$_POST['do_domain'])
       $woocommerce-&gt;add_error( __('Please select your domain type.') );
   }
  
  
  
  
   add_action('woocommerce_checkout_update_order_meta', 'my_custom_checkout_field_update_order_meta');
  
   function my_custom_checkout_field_update_order_meta( $order_id ) {
     if ($_POST['do_domain']) update_post_meta( $order_id, 'do_domain', esc_attr($_POST['do_domain']));
   }
  
  
   add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_custom_checkout_field_display_admin_order_meta', 10, 1 );
  
   function my_custom_checkout_field_display_admin_order_meta($order){
       echo '&lt;p&gt;&lt;strong&gt;'.__('Domain Purchase').':&lt;/strong&gt; ' . $order-&gt;order_custom_fields['do_domain'][0] . '&lt;/p&gt;';
   }
  </code></pre>