Commerce : adding optional insurance block to shopping cart form : ajax callback
To implement an optional insurance field in the shopping cart : first, follow question steps 1 to 6. 

For a nice ajax replacement, create a very simple Order total view with a Global: Custom text field (which we'll hide with a css class, just to have the minimum :one field) and put Commerce Order: Order total field in footer.

Then alter the form and setup the ajax callback :

function vts_insurance_form_views_form_cart_field_assurances_block_alter(&amp;$form, &amp;$form_state, $form_id) {
  //add ajax to our field
  $form['field_order_assurances'][0]['field_order_assurances']['und']['#ajax'] = array(
    'callback' =&gt; 'vts_insurance_cart_refresh', 
    'progress' =&gt; array('type' =&gt; 'throbber', 'message' =&gt; ''),
  );
  //unset unused buttons
  unset($form['field_order_assurances'][0]['actions']['submit']);
  unset($form['actions']);
}

function vts_insurance_cart_refresh(&amp;$form, &amp;$form_state) {  
  $order = commerce_cart_order_load($GLOBALS['user']-&gt;uid);

  //set the order insurance field value &amp; save it
  $order-&gt;field_order_assurances['und'][0]['tid'] = $form_state['values']['field_order_assurances'][0]['field_order_assurances']['und'][0]['tid'];
  commerce_order_save($order);
  commerce_cart_order_refresh($order);

  //Display a message to customer
  $term = taxonomy_term_load($order-&gt;field_order_assurances['und'][0]['tid']);
  dsm(t('Insurance : you selected ').$term-&gt;name);
  $commands[] = ajax_command_replace('.messages.status', theme('status_messages'));

  //Refresh the cart total display
  $cart_total = commerce_embed_view('shopping_cart_total', 'block', array($order-&gt;order_id));
  $commands[] = ajax_command_replace('.view-shopping-cart-total', $cart_total);

  return array('#type' =&gt; 'ajax', '#commands' =&gt; $commands);
}


In the module js file, play with your DOM elements to display them as wished

(function ($) {

  $(document).ready(function(){
    //A wrapper for the first shopping cart total refresh                   
    $('.commerce-order-handler-area-order-total').wrap('&lt;div class="view-shopping-cart-total"&gt;&lt;/div&gt;');
    //Move the editable field above buttons
    var assurances = $('.view-id-cart_field_assurances').detach();
    $('.view-shopping-cart-total').before(assurances);
    //A wrapper for ajax messages
    var insurance_message = $("&lt;div class='messages status insurance'&gt;&lt;/div&gt;");
    insurance_message.appendTo(assurances).hide();
  });

})(jQuery);


A rule setting up a Fee price component, depending on the insurance field percentage value.

{ "rules_calcul_des_assurances" : {
    "LABEL" : "Calcul des assurances",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "Commerce Cart" ],
    "REQUIRES" : [ "commerce", "rules", "commerce_fees" ],
    "ON" : { "commerce_fees_order" : [] },
    "IF" : [
      { "entity_exists" : {
          "type" : "commerce_order",
          "property" : "order_id",
          "value" : [ "commerce-order:order-id" ]
        }
      },
      { "entity_has_field" : { "entity" : [ "commerce-order" ], "field" : "field_order_assurances" } }
    ],
    "DO" : [
      { "data_calc" : {
          "USING" : {
            "input_1" : [ "commerce-order:commerce-order-total:amount-decimal" ],
            "op" : "*",
            "input_2" : [ "commerce-order:field-order-assurances:field-pourcentage" ]
          },
          "PROVIDE" : { "result" : { "assurance_cout" : "Co\u00fbt de l\u0027assurance" } }
        }
      },
      { "commerce_fees_apply" : {
          "entity" : [ "commerce-order" ],
          "fee" : "assurances",
          "amount" : [ "assurance-cout" ],
          "currency_code" : "EUR"
        }
      }
    ]
  }
}


With such implementation, it is possible to add any kind of field in the shopping cart footer, allowing customers to choose options that will change the order total adding a price component, with Ajax feature. Nice.