Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
1  
If possible shift to Drupal Commerce and use the Rules magic sauce :P –  Gokul N K Sep 2 '13 at 7:22
add comment

1 Answer 1

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().

foreg:

function hook_order(){
switch ($op) {
.....................
case 'save':
if($arg1->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->order_id, 
      'shipping',
      t('Residential Delivery Fee'), 
      100, 
      NULL,
      array () 
    );

 }
}

I successfully implemented this idea for one of my client site

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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