How do I add conditional shipping cost to an order? I am building an e-commerce site. When a shippable item is added to the cart I have to add some fixed shipping cost to the order which I am able to do with flat rate. But I have to 
add an option "Residential Delivery Fee" while showing shipping cost on checkout page. If user select this option during checkout then I have to add another shipping cost to the order.

I am unable to figure out that how to add this conditional shipping cost.
Here the idea,


Using hook_checkout_pane() include your option Residential Delivery Fee as checkbox 
Then while saving order check if user selected this option. Use hook_order 
If user chose this option, you can add your shipping charge as line item with the function uc_order_line_item_add().


foreg: 

function hook_order(){
switch ($op) {
.....................
case 'save':
if($arg1-&gt;residential){
//if the checkbox was selected, we add the line item to the order. the following function  will add 100 to order total as shipping charge
uc_order_line_item_add
    (
      $arg1-&gt;order_id, 
      'shipping',
      t('Residential Delivery Fee'), 
      100, 
      NULL,
      array () 
    );

 }
}