How to Use Delivery Type options to calculate Shipping Quote

Posts: 5
Joined: 10/13/2008

Hi

I have created two modules, the first is a shipping module, to which I have finished and am testing so far. The shipping module is based upon the weight based shipping solutions and geo-shipping solution. Each destination has its own shipping rate per kg and also a standard charge amount.

My second module is an add to the first module. Its a Delivery type options module were the customer gets to select two options "Standard" or "Express" from a drop down combo box, to which I created a pane for called "Select Delivery Type Method" and is placed above the "Calculate Shipping Cost Pane"

The idea here is depending on how customer whats their order delivered to them.

If Standard (which is the default is selected) then the shipping quote is calculated by the rate/kg of the destination multiplied by the order weight in kg, and exludes the basic charge fee.

Eg. Shipping Charge = (Weight of Product * Rate/kg)

If Express Selected, then the shipping quote is calculated by the rate/kg of the destination multiplied by the order weight in kg, and plus the basic charge fee.
Eg. Charge = (Weight of Product * Rate/kg) + Express Charge)

My problem is having to reference whether (in the "Delivery Type Method Pane" above the "calculate shipping cost pane") STANDARD or EXPRESS is selected and create a Case or If Then Else Statement to calculate the shipping cost.

Apart from this, I am new to drupal and ubercart and have spent nearly two solid weeks learning it. In addition, I dont know PHP and MYSQL and am also learning. But have been able to write a few things, most of my time is debugging and searching for help, I have not been able to find anything to resolve my current problem above.

Please any help and all help would be greatly appreciated to resolve this issue.

Kind Regards
OJ

Posts: 2259
Joined: 08/07/2007
AdministratoreLiTe!

Instead of having a checkout pane to choose whether it's standard or express shipping, it might be easier to have your shipping module to provide two shipping methods. Having two methods gives the customer the choice in the Shipping Quote pane automatically, and you will have two separate functions to calculate each rate. If you're clever, you might be able to have the express shipping callback call the standard method, and then add the express charge to it so you don't have to have duplicate code.

Posts: 5
Joined: 10/13/2008

Hi Lyle,

Thanks very much for your response. Is it possible to reference data in another pane from our Shipping Module

*********Delivery Type Pane Function*********************

function uc_checkout_pane_deliverytype($op, &$arg1, $arg2) {
switch ($op) {
case 'view':
$description = t('Please select how you would want your order delivered to you. Note Express comes with a K30.00 surcharge!');

$options = preg_split('/[\r\n]+/', variable_get('uc_deliverytype_options', ''));
for ($i = 0; $i < count($options); $i++) {
if (empty($options[$i])) {
unset($options[$i]);
}
}
$options = array_merge(array(t('Standard')), $options,
array(t('Express')));
$contents['deliverytype_source'] = array(
'#type' => 'select',
'#title' => t('Select a delivery type method'),
'#options' => drupal_map_assoc($options),
'#default_value' => $arg1->deliverytype['source'],
);
return array('description' => $description, 'contents' => $contents);

case 'process':
{
$arg1->deliverytype['source'] = $arg2['deliverytype_source'];
}
return TRUE;

case 'review':

{
$review[] = array('title' => t('Delivery type selected'), 'data' => $arg1->deliverytype['source']);
}
return $review;
}
}

*************************

I want to reference the value selected there and use in my if then else statemeng in my shipping module part of the coding below

*********** Formula in shipping module to calculate shipping cost

case 'weight':
$units = $rule->units;
//$deliverytype = variable_get('uc_deliverytype', array('deliverytype_source' => 'Standard'));
$basic_charge = $rule->basic_charge;
// We have to normalise the rate the same way we did the weight if this is to work.
//if ($deliverytype == t('Standard'))
if (variable_get('uc_deliverytype_source', '') == t('Standard'))
{
$rate += _uc_normalise_weight($rule->rate, $rule->units) * $pkgweight;
//print $deliverytype;
}
else
{
$rate += ((_uc_normalise_weight($rule->rate, $rule->units) * $pkgweight) + $rule->basic_charge);
}

break;
}
}

*************

Can I do this, as I have spent some time now trying to develope this whole shipping module thing, and am running short on ideas, and time.

Please verify.

All help and any help is good help, as long as we resolve this issue.

Thanks
OJ

Posts: 5
Joined: 10/13/2008

Hasn't anyone, ever tried to reference data from a pane?

Another question, since I want to be to return a shipping quote based upon what the user selects in my "Delivery Type Pane" combo box, "Standard" or "Express"

Can I use, the workflow_ng to set a criteria that checks this pane, and see if Standard or Express has been selected, then return a shipping quote appropriate?

And how do I do this, since, I can not find in the add conditions a area to add my delivery type method options condition.

Thanks,
OJ
All Help, and any help is greatly appreciated

Posts: 92
Joined: 04/23/2008