title: How to change product (or quantity) on woocommerce checkout page
body: <p>looking for some help here</p>
  
  <p>so my plan is to have the option to change the product in the checkout page with some radio boxes.
  <a href="https://i.stack.imgur.com/aXJVs.png" rel="nofollow noreferrer">something that looks like this</a></p>
  
  <p>I've been trying to change the code bellow that is original to add fees.
  My goal would be to have the different products on the radio box or at least that it change the quantity.</p>
  
  <pre><code>/**
   * @snippet       Dynamic Radio Buttons Fees - WooCommerce Checkout
   * @how-to        Watch tutorial @ https://businessbloomer.com/?p=19055
   * @sourcecode    https://businessbloomer.com/?p=79316
   * @author        Rodolfo Melogli
   * @compatible    WooCommerce 3.5.1
   * @donate $9     https://businessbloomer.com/bloomer-armada/
   */
  
  // Part 1 
  // Display Radio Buttons
  // Uses woocommerce_form_field()
  
  add_action( 'woocommerce_review_order_before_payment', 'bbloomer_checkout_radio_choice' );
  
  function bbloomer_checkout_radio_choice() {
  
     $chosen = WC()-&gt;session-&gt;get('radio_chosen');
     $chosen = empty( $chosen ) ? WC()-&gt;checkout-&gt;get_value('radio_choice') : $chosen;
     $chosen = empty( $chosen ) ? 'no_option' : $chosen;
  
     $args = array(
     'type' =&gt; 'radio',
     'class' =&gt; array( 'form-row-wide' ),
     'options' =&gt; array(
        'no_option' =&gt; 'No Option',
        'option_1' =&gt; 'Option 1 ($10)',
        'option_2' =&gt; 'Option 2 ($30)',
     ),
     'default' =&gt; $chosen
     );
  
     echo '&lt;div id="checkout-radio"&gt;';
     echo '&lt;h3&gt;Customize Your Order!&lt;/h3&gt;';
     woocommerce_form_field( 'radio_choice', $args, $chosen );
     echo '&lt;/div&gt;';
  
  }
  
  // Part 2 
  // Add Fee and Calculate Total
  // Based on session's "radio_chosen"
  
  #2 Calculate New Total
  
  add_action( 'woocommerce_cart_calculate_fees', 'bbloomer_checkout_radio_choice_fee', 20, 1 );
  
  function bbloomer_checkout_radio_choice_fee( $cart ) {
  
    if ( is_admin() &amp;&amp; ! defined( 'DOING_AJAX' ) ) return;
  
    $radio = WC()-&gt;session-&gt;get( 'radio_chosen' );
  
    if ( "option_1" == $radio ) {
     $fee = 10;
    } elseif ( "option_2" == $radio ) {
     $fee = 30;
    }
  
    $cart-&gt;add_fee( __('Option Fee', 'woocommerce'), $fee );
  
  }
  
  // Part 3 
  // Refresh Checkout if Radio Changes
  // Uses jQuery
  
  add_action( 'wp_footer', 'bbloomer_checkout_radio_choice_refresh' );
  
  function bbloomer_checkout_radio_choice_refresh() {
  if ( ! is_checkout() ) return;
      ?&gt;
      &lt;script type="text/javascript"&gt;
      jQuery( function($){
          $('form.checkout').on('change', 'input[name=radio_choice]', function(e){
              e.preventDefault();
              var p = $(this).val();
              $.ajax({
                  type: 'POST',
                  url: wc_checkout_params.ajax_url,
                  data: {
                      'action': 'woo_get_ajax_data',
                      'radio': p,
                  },
                  success: function (result) {
                      $('body').trigger('update_checkout');
                  }
              });
          });
      });
      &lt;/script&gt;
      &lt;?php
  }
  
  // Part 4 
  // Add Radio Choice to Session
  // Uses Ajax
  
  add_action( 'wp_ajax_woo_get_ajax_data', 'bbloomer_checkout_radio_choice_set_session' );
  add_action( 'wp_ajax_nopriv_woo_get_ajax_data', 'bbloomer_checkout_radio_choice_set_session' );
  
  function bbloomer_checkout_radio_choice_set_session() {
      if ( isset($_POST['radio']) ){
          $radio = sanitize_key( $_POST['radio'] );
          WC()-&gt;session-&gt;set('radio_chosen', $radio );
          echo json_encode( $radio );
      }
      die();
  }
  </code></pre>
  
  <p><a href="https://businessbloomer.com/woocommerce-add-checkout-fees-based-on-radio-button-choice-ajax/" rel="nofollow noreferrer">code source</a></p>