title: Custom form fields in cart and get the data in checkout on Woocommerce
body: <p>Adding From,To and Message fields in cart page before checkout.I have added some code in cart.php file but after adding that code the cart page is displaying blank.</p>
  
  <pre><code>/**
  * Add the order_comments field to the cart
  **/
   add_action('woocommerce_cart_collaterals', 
  'order_comments_custom_cart_field');
  
   function order_comments_custom_cart_field() {
    echo '&lt;div id="cart_order_notes"&gt;';
    ?&gt;
   &lt;div class="customer_notes_on_cart"&gt;
   &lt;label for="customer_notes_text"&gt;&lt;?php _e('Order notes','woocommerce'); ?&gt; 
   &lt;/label&gt;
   &lt;textarea id="customer_notes_text"&gt;&lt;/textarea&gt;
   &lt;/div&gt;
   &lt;?php
    }
    /**
    * Process the checkout and overwriting the normal button
    *
    */
  function woocommerce_button_proceed_to_checkout() {
  $checkout_url = wc_get_checkout_url();
  ?&gt;
     &lt;form id="checkout_form" method="POST" action="&lt;?php echo $checkout_url; 
    ?&gt;"&gt;
     &lt;input type="hidden" name="customer_notes" id="customer_notes" value=""&gt;
     &lt;a  href="#" onclick="document.getElementById('customer_notes').value=document.getElementById('customer_notes_text').value;document.getElementById('checkout_form').submit()" class="checkout-button button alt wc-forward"&gt;
     &lt;?php _e( 'Proceed to checkout', 'woocommerce' ); ?&gt;&lt;/a&gt;
     &lt;/form&gt;
     &lt;?php
     }
    // getting the values in checkout again
   add_action('woocommerce_checkout_before_customer_details',function(){
   ?&gt;
   &lt;script&gt;
   jQuery( document ).ready(function() {
  jQuery('#order_comments' ).val("&lt;?php echo 
   sanitize_text_field($_POST['customer_notes']); ?&gt;");
    });
   &lt;/script&gt;
  &lt;?php 
   });
  </code></pre>
  
  <p>In cart.php i have added this code at the bottom before closing the form tag as well as after the form tag.But i am getting a blank page after adding this piece of code in cart.php.</p>
  
  <p><a href="https://i.stack.imgur.com/Kzhgi.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Kzhgi.jpg" alt="enter image description here"></a></p>
  
  <p>In the same format i am trying to get those from,to and message fields.</p>