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.

  • 1
    If possible shift to Drupal Commerce and use the Rules magic sauce :P
    – Gokul N K
    Sep 2 '13 at 7:22
  • Drupal Commerce for Drupal 6? That's some magic ...
    – anonymous
    Dec 24 '20 at 22:20

Here the idea,

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


function hook_order(){
switch ($op) {
case 'save':
//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
      t('Residential Delivery Fee'), 
      array () 


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.