can't programatically update line item on drupal commerce order I want 'sell' a donation for custom donation amounts, and I know that to do this, I will need to use line items. I wrote the following code which I thought would do the trick, but when I go to /cart, I see that the price has remained the same. 

global $user;
  if(user_is_logged_in()) {
    //$order_id = commerce_cart_order_id($user->uid);
    //$order = commerce_order_load($order_id);
    $order = commerce_cart_order_load($user->uid); 
  }
  else {
    $order = commerce_cart_order_load();  //no uid since user is not logged in. attempts to load an anonymous order from the session.
  }
  //var_dump($form_state['values']['donation-custom-amount']);
  $lineItem = commerce_line_item_load($order->commerce_line_items['und'][0]['line_item_id']);
  if($form_state['values']['donation-custom-amount'] !== "") {  //if the user entered a custom amount
    $lineItem->commerce_unit_price['und'][0]['amount'] = $form_state['values']['donation-custom-amount'];
    $lineItem->commerce_total_price['und'][0]['amount'] = $form_state['values']['donation-custom-amount'];
  } 
  else {
    $lineItem->commerce_unit_price['und'][0]['amount'] = $form_state['values']['donation-amount'];
  }
  commerce_line_item_save($lineItem);   

I checked that $form_state['values'] was giving me the form data, and there are no errors, just no price change.
Recently I've updated some other line item fields on commerce_add_to_cart_submit() via this code:

$line_item = commerce_line_item_load($lit_id);
$line_item-&gt;field_product_options[LANGUAGE_NONE][0]['value'] = $size;
commerce_line_item_save($line_item);
entity_get_controller('commerce_line_item')-&gt;resetCache(array($line_item-&gt;line_item_id));


I hope this will help someone.