title: WooCommerce Change Total Price on Checkout by custom field
body: <p>I'm struggling finding a solution to this problem:</p>
  
  <p>I need to create a custom number field on checkout page and change total price according to this field. 
  The user can put a number starting from 4 to maximum the total Cart quantity and gets a discount based on this number.</p>
  
  <p>How can I update total price after user set number field?</p>
  
  <p>Below there is my code to add a custom field to checkout page</p>
  
  <pre><code>/**
  
  * Add custom field to the checkout page
  
  */
  
  add_action('woocommerce_before_checkout_form', 'custom_number_field');
  
  function custom_number_field($checkout)
  
  {
  
  echo '&lt;div id="custom_checkout_field"&gt;&lt;h2&gt;' . __('Vuoto a rendere') . '&lt;/h2&gt;';
  
  woocommerce_form_field('custom_field_name', array(
  
  'type' =&gt; 'number',
  
  'class' =&gt; array(
  
  'my-field-class form-row-wide'
  
  ) ,
  
  'label' =&gt; __('Quanto vuoi rendere?') ,
  
  'placeholder' =&gt; __('New Custom Field') ,
  
  ) ,
  
  $checkout-&gt;get_value('custom_field_name'));
  
  echo '&lt;/div&gt;';
  
  }
  </code></pre>
  
  <p>Then I read that it's not possible updating total price directly into checkout page and I need to refresh page using a button and passing to the new page the value of my custom field. </p>
  
  <p>So I need to use this WooCommerce field:</p>
  
  <pre><code>add_filter( 'woocommerce_calculated_total', 'change_calculated_total', 10, 2 );
  function change_calculated_total( $total, $cart ) {
      return $total - "value of my custom field";
  }
  </code></pre>
  
  <p>How can I create a button link with the value of my custom field and pass it to the WooCommerce function to update cart?
  I was thinking to use php GET and putting the value of custom field inside the link button and then retrieve the value from the link inside the cart function.</p>
  
  <p>Some help will be highly appreciated.</p>