How to add a line item to show total cost in Ubercart 2? I am using Ubercart 2 and I want to add a line item, which should add the total cost of all items instead of sell price. I tried to take the code from generic line item hook and used this to callback:

for each($op-&gt;products as item) {
  $cost += $item-&gt;cost; 
}


I want this line item to appear in the AJAX cart, which I am using now. It should appear in the user panel before checkout and it should also shown in the user and store admin order emails. It is not working as of now. Is the code I am adding correct or I have done any misplacement?
There is uc_order_pane_line_items_add


  Order pane submit callback: Add a line item to an order.


function uc_order_line_item_add($order_id, $type, $title, $amount, $weight = NULL, $data = NULL) {
  if (is_null($weight)) {
    $weight = _uc_line_item_data($type, 'weight');
  }

  $line_item = array(
    'order_id' =&gt; $order_id, 
    'type' =&gt; $type, 
    'title' =&gt; $title, 
    'amount' =&gt; $amount, 
    'weight' =&gt; $weight, 
    'data' =&gt; $data,
  );
  drupal_write_record('uc_order_line_items', $line_item);

  return $line_item;
}