Hi all,

I am using ubercart 3 with drupal 7. I want to create custom line item for additional handling charges. Below code is working fine but the additional handling amount is not added with the total, but its added with the subtotal. Any one pls tell what i am doing wrong?

function mycustom_uc_order($op, $order, $arg2) {
switch ($op) {
case 'save':
$package_lineitem_id = $ups_charges = $package_lineitem_index = '';
$line_items = uc_order_load_line_items($order);
foreach ($line_items as $key => $line_item) {
if ($line_item['type'] == 'shipping' && $line_item['amount'] != '') {
$ups_charges = $line_item['line_item_id'];
} elseif($line_item['type'] == 'custom_package_charges'){
$package_lineitem_id = $line_item['line_item_id'];
$package_lineitem_index = $key;
}
}
$pack_charges = 5;
// If packaging charges line item exists update else create a new one
if(empty($package_lineitem_id)){
$order->line_items[] = uc_order_line_item_add($order->order_id, 'custom_package_charges', 'Additional Handling Charges for Packaging', $pack_charges,5);
} else {
uc_order_update_line_item($package_lineitem_id, 'Additional Handling Charges for Packaging', $pack_charges);
$order->line_items[$package_lineitem_index]['amount'] = $pack_charges;
}

break;
}
}

Comments

riswana created an issue. See original summary.

TR’s picture

Title: Order total not updating for the custom line item ubercart drupal 7 » Order total not updating for the custom line item
Component: Shipping quotes » Other
Status: Active » Fixed

You have to implement hook_uc_line_item(). Please use Google to find many example of this. You can also search this issue queue, where you will find issues like #1960556: Creation of line items that have help for implementing a custom line item.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.