Somebody help or give me a lead. Anybody willing to help out for a fee?
Thank you in advance for any help.
I am developing a shipping quote method that is weight-based. The calculation of the shipping quote works like this: 1. Customer completes the delivery address details on the delivery pane at checkout. 2. Customer selects for delivery type either “Standard” or “Expess” in a new pane that I have included at checkout. 3. The shipping quote calculation will need zone and delivery type to return a shipping quote. The rates are stored in a table by zones. If the customer selected “Standard” as delivery type then the quote returned is (shipping rate * order weight) else quote is ((shipping rate * order weight) + Basic charge). Basic charge exists in the rate table.
My problem is how do I reference the delivery type information selected by the customer on the checkout form (deliverytype pane) so that I can use it in calculating the shipping quote.
The code for the new pane is:
<?php
function uc_deliverytype_checkout_pane() {
$panes[] = array(
'id' => 'deliverytype',
'callback' => 'uc_checkout_pane_deliverytype',
'title' => t('Delivery type method'),
'desc' => t('Customer selects how they want their order delivery.'),
'weight' => 5,
);
return $panes;
?>The callback function is:
<?php
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.');
$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;
}
}
?>Here is the hook_quote. Notice the code that's commented out is where my problem is.
<?php
function uc_pngquote_quote($products, $details) {
$rate = 0;
$basic_charge = 0;
//get shipping info
$postal_code = $details['postal_code'];
$country = $details['country'];
$zone = $details['zone'];
//$deliverytype = $details['deliverytype'];
//$deliverytype = variable_get('deliverytype','');
//get order weight
$pkgweight = 0;
$pkgprice = 0;
if(count($rules))
watchdog('Ubercart shipping', "No shipping rules selected for: Post code: '$postal_code', zone: '$zone', country '$country', total weight: $pkgweight kgs");
if($rules) {
foreach($rules as $rule) {
switch ($rule->flat_weight) {
case 'flat':
$rate += $rule->rate;
break;
case 'weight':
$units = $rule->units;
$basic_charge = $rule->basic_charge;
// We have to normalise the rate the same way we did the weight if this is to work.
//$rate += _uc_normalise_weight($rule->rate, $rule->units) * $pkgweight;
if ($deliverytype == t('Standard')) {
$rate += _uc_normalise_weight($rule->rate, $rule->units) * $pkgweight;
}
else {
$rate += ((_uc_normalise_weight($rule->rate, $rule->units) * $pkgweight) + $rule->basic_charge);
}
break;
}
}
$method = uc_pngquote_shipping_method();
$quotes[] = array('rate' => $rate, 'format' => uc_currency_format($rate), 'option_label' => $rule->name);
}
return $quotes;
}
?>



Joined: 09/18/2008