Alter cart unit price and total amount
I finally made it work.

function mymodule_commerce_commerce_cart_order_refresh($order_wrapper) {         
  foreach ($order_wrapper-&gt;commerce_line_items as $delta =&gt; $line_item_wrapper) {
    $line_item = $line_item_wrapper-&gt;value();                                   
    $type = $line_item_wrapper-&gt;commerce_product-&gt;value()-&gt;type;                
    if ($type === 'insurance') {                                                
      $package_price   = $line_item_wrapper-&gt;commerce_product-&gt;field_package_ref-&gt;commerce_price-&gt;amount-&gt;value();
      $warranty_price  = $line_item_wrapper-&gt;commerce_product-&gt;commerce_price-&gt;amount-&gt;value();
      $amount = _mymodule_commerce_calculate_policy_price($warranty_price, $package_price);
    }                                                                           
    elseif ($type === 'little_product') {                                       
      $amount = $line_item_wrapper-&gt;commerce_product-&gt;commerce_price-&gt;amount-&gt;value();
    }                                                                           
    else {                                                                      
      return TRUE;                                                              
    }                                                                           
    $qty = $line_item-&gt;quantity;                                                
    // This sets the unit price by adding a component price 'base_price'.        
    mymodule_commerce_line_item_price_amount($line_item, $amount, 'commerce_unit_price');
    mymodule_commerce_line_item_price_amount($line_item, $qty * $amount, 'commerce_total');
    commerce_line_item_save($line_item);                                        
    entity_get_controller('commerce_line_item')-&gt;resetCache(array($line_item-&gt;line_item_id));
  }                                                                             
}