title: Radio Buttons to select specific text inputs during checkout in WooCommerce
body: <p>I am adding custom fields to my checkout area in WooCommerce through my child theme's functions.php. I have added some text inputs, but I need to add two radio buttons that will select/ activate two seperate "sets" of text inputs.</p>
  
  <p>Basically I need a way for my customers to be able to select Button A: enter payment info <strong>OR</strong> select Button B: and enter a PO Number. I need to make sure that the button that is <strong>NOT</strong> selected will not write to the database and hold up / produce errors during checkout.</p>
  
  <p>If you go to the <a href="http://devlabstorage.ltyc.org/products" rel="nofollow">products page</a> and add a product, then navigate to the <a href="http://devlabstorage.ltyc.org/checkout/" rel="nofollow">checkout area</a> you can see what I have already done. The code is below:</p>
  
  <pre><code>add_action('woocommerce_after_order_notes', 'custom_checkout_field');
  function custom_checkout_field( $checkout ) {
  
  echo '&lt;div id="payment_info"&gt;&lt;h3&gt;'.__('Payment Information').'&lt;/h3&gt;';
  
  woocommerce_form_field( 'credit_card_name', array(
      'type'          =&gt; 'text',
      'class'         =&gt; array('form-row-wide'),
      'label'         =&gt; __('Name on Credit Card'),
      'required'    =&gt; true,
      'placeholder'       =&gt; __(''),
      ), $checkout-&gt;get_value( 'credit_card_name' ));
  
  woocommerce_form_field( 'card_type', array(
      'type'          =&gt; 'select',
      'class'         =&gt; array(''),
      'label'         =&gt; __('Card Type'),
      'required'    =&gt; true,
      'placeholder'       =&gt; __(''),
      'options'     =&gt; array(
      'American Express' =&gt; __('American Express'),
      'Discover' =&gt; __('Discover'),
      'Mastercard' =&gt; __('Mastercard'),
      'Visa' =&gt; __('Visa')
      )), $checkout-&gt;get_value( 'card_type' ));
  
  woocommerce_form_field( 'card_number', array(
      'type'          =&gt; 'text',
      'class'         =&gt; array(''),
      'label'         =&gt; __('Card Number'),
      'required'    =&gt; true,
      'placeholder'       =&gt; __('XXXX-XXXX-XXXX-XXXX'),
      ), $checkout-&gt;get_value( 'card_number' ));
  
  woocommerce_form_field( 'card_expiration_month', array(
      'type'          =&gt; 'select',
      'class'         =&gt; array('form-row-first'),
      'label'         =&gt; __('Expiration Month'),
      'required'    =&gt; true,
      'placeholder'       =&gt; __('- Select Month -'),
      'options'     =&gt; array(
      '1' =&gt; __('1'),
      '2' =&gt; __('2'),
      '3' =&gt; __('3'),
      '4' =&gt; __('4'),
      '5' =&gt; __('5'),
      '6' =&gt; __('6'),
      '7' =&gt; __('7'),
      '8' =&gt; __('8'),
      '9' =&gt; __('9'),
      '10' =&gt; __('10'),
      '11' =&gt; __('11'),
      '12' =&gt; __('12')
      )), $checkout-&gt;get_value( 'card_expiration_month' ));
  
  woocommerce_form_field( 'card_expiration_year', array(
      'type'          =&gt; 'select',
      'class'         =&gt; array('form-row-last'),
      'label'         =&gt; __('Expiration Year'),
      'required'    =&gt; true,
      'placeholder'       =&gt; __('- Select Year -'),
      'options'     =&gt; array(
      '2013' =&gt; __('2013'),
      '2014' =&gt; __('2014'),
      '2015' =&gt; __('2015'),
      '2016' =&gt; __('2016'),
      '2017' =&gt; __('2017'),
      '2018' =&gt; __('2018'),
      '2019' =&gt; __('2019'),
      '2020' =&gt; __('2020')
      )), $checkout-&gt;get_value( 'card_expiration_year' ));
  
  woocommerce_form_field( 'security_code', array(
      'type'          =&gt; 'text',
      'class'         =&gt; array('form-row-first'),
      'label'         =&gt; __('Security Code'),
      'required'    =&gt; true,
      'placeholder'       =&gt; __(''),
      ), $checkout-&gt;get_value( 'security_code' ));
  
  woocommerce_form_field( 'order_number', array(
      'type'          =&gt; 'text',
      'class'         =&gt; array('form-row-wide'),
      'label'         =&gt; __('PO Number (if required)'),
      'placeholder'       =&gt; __(''),
      ), $checkout-&gt;get_value( 'order_number' ));
  
  echo '&lt;/div&gt;';
  </code></pre>
  
  <p>So it needs to look like this:</p>
  
  <p><em>Payment Information</em></p>
  
  <p>[x] Credit Card<br />
  Name [ __ active input area __ ]<br />
  Card Number [ __ active input area __ ]
  etc.</p>
  
  <p>[ _ ] PO Number<br />
  Enter Number [ __ inactive input area __ ]</p>