title: Dynamic shipping fee based on custom radio buttons in Woocommerce
body: <p>In Woocommerce, I have added two custom radio buttons on the checkout page and on click, I called an ajax function to add a delivery fee. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>$(document).on('change','#shipping_method_0_local_pickup5',function(e) {              
              $('.woocommerce-shipping-fields').css({
                  'display': 'none'
              });
  
                          $("#deli").css("display","block"); 
                          var selected = $("input[type='radio'][name='post-del']:checked");
                          var selectedVal = selected.val();               
                          var pickurl= "&lt;?php echo admin_url('admin-ajax.php');?&gt;?action=delivery";
                          $.ajax({   
                              url: pickurl,
                              type: "POST",
                              data:{
                                  input:selectedVal,                       
                              },            
                              success: function(responseText) 
                              { 
                                  jQuery(".order-total .woocommerce-Price-amount").html(responseText);
                                  //$(".discount_code").css("display","block"); 
                              }
                          }); 
  
          });
  </code></pre>
  
  <p><strong>when the radio button click I want to add addition price $2 on my total.</strong></p>
  
  <pre><code>add_action( 'wp_ajax_delivery', 'delivery' );
  add_action( 'wp_ajax_nopriv_delivery', 'delivery' );
  
  function delivery()
  {      
      //My code  
      do_action( 'woocommerce_cart_calculate_fees', 'prefix_add_discount_line' ); // not working
      exit;
  }
  </code></pre>
  
  <p><strong>Note: This is the hook which updates the code</strong></p>
  
  <pre><code>add_action( 'woocommerce_cart_calculate_fees', 'prefix_add_discount_line' );
  function prefix_add_discount_line( $cart ) {
  
      $discount = $cart-&gt;subtotal + 2;
  
      $cart-&gt;add_fee( __( 'Delivery', 'yourtext-domain' ) , +$discount );
  
  }
  </code></pre>