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->products as item) {
  $cost += $item->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' => $order_id, 
    'type' => $type, 
    'title' => $title, 
    'amount' => $amount, 
    'weight' => $weight, 
    'data' => $data,
  drupal_write_record('uc_order_line_items', $line_item);

  return $line_item;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.