Hi,
I am very new to Drupal, and have started learning Drupal and Ubercart.
I have testing modules and stuff and came across the Lead Tracker module, my friend and I have done some reading on it, and have tried modifying it to suit our needs.
Our only problem is that the data does not seem to appear on the Review Order Page when we hit the submit Button,
Please, oh please can some help us...
Below is our code we modified original from the Lead Tracker. We use Drupal 5
Thanks.
Please forgive me if I have submitted this in wrong place.
NOTE. This module calculates shipping cost based upon the province to which the cargo will be travelling to, and charges a basic depending on whether the customer chooses standard or express.
**************************************
<?php
// $Id$
/*
** Implementation of hook_perm()
*/
function uc_pngquote_perm() {
return array('configure pngquote');
}
/**
* @file
* PNG quote module that defines specific geographical and weight rules for shipping, based on flat rate and per weight rate
*/
/******************************************************************************
* Drupal Hooks *
******************************************************************************/
/**
* Implementation of hook_menu().
*/
function uc_pngquote_menu($may_cache){
$items = array();
if ($may_cache){
$items[] = array('path' => 'admin/store/settings/quotes/methods/pngquote',
'title' => t('PNG Quote Settings'),
'access' => user_access('configure pngquote'),
'callback' => 'drupal_get_form',
'callback arguments' => array('uc_pngquote_form', 0),
'type' => MENU_LOCAL_TASK,
);
$items[] = array('path' => 'admin/store/settings/quotes/methods/pngquote/edit',
'title' => t('Edit pngquote rule'),
'access' => user_access('configure pngquote'),
'callback' => 'drupal_get_form',
'callback arguments' => array('uc_pngquote_form'),
'type' => MENU_CALLBACK,
);
$items[] = array('path' => 'admin/store/settings/quotes/methods/pngquote/copy',
'access' => user_access('configure pngquote'),
'callback' => 'uc_pngquote_copy',
'type' => MENU_CALLBACK,
);
$items[] = array('path' => 'admin/store/settings/quotes/methods/pngquote/delete',
'title' => t('Delete pngquote rule'),
'access' => user_access('configure pngquote'),
'callback' => 'drupal_get_form',
'callback arguments' => array('uc_pngquote_delete'),
'type' => MENU_CALLBACK,
);
}
else{
//drupal_add_css(drupal_get_path('module', 'uc_pngquote') .'/uc_pngquote.css');
$items[] = array('path' => 'pngquote/calculate',
'access' => true,
'callback' => 'uc_pngquote_javascript',
'type' => MENU_CALLBACK,
);
}
return $items;
}
/******************************************************************************
* Übercart Hooks *
******************************************************************************/
/**
* Implementation of hook_checkout_pane()
*/
function uc_pngquote_checkout_pane() {
$panes[] = array(
'id' => 'deliverytype',
'callback' => 'uc_checkout_pane_deliverytype',
'title' => t('Select delivery type method'),
'desc' => t('Customer to select delivery type method'),
'weight' => 5,
);
return $panes;
}
/******************************************************************************
* Menu Callbacks *
******************************************************************************/
function uc_pngquote_form($pngquoterate_id = 0, $form_values = null){
$form = array('#multistep' => true, '#redirect' => false);
if ($pngquoterate_id != 0 && is_null($form_values)){
$form_values = db_fetch_array(db_query("SELECT * FROM {uc_pngquote} WHERE id = %d", $pngquoterate_id));
$form_values['step'] = 0;
$form_values['op'] = t('Next');
}
if (isset($form_values['area_zone'])){
$form_values['area'] = $form_values['area_zone'];
}
switch ($form_values['op']){
case t('Add Shipping Rate Rule'):
case t('Next'):
if(($form_values['type'] == 'anywhere') && ($form_values['step'] == 1))
$form_values['step'] =3;
else
$form_values['step']++;
break;
case t('Back'):
if(($form_values['type'] == 'anywhere') && ($form_values['step'] == 3))
$form_values['step']=1;
else
$form_values['step']--;
break;
default:
$form_values['step'] = 0;
break;
}
$form['step'] = array('#type' => 'hidden', '#value' => isset($form_values['step']) ? $form_values['step'] : 0);
switch ($form_values['step']){
case 0: // View pngquote rate rules.
$form['start'] = array('#type' => 'submit', '#value' => t('Add Shipping Rate Rule'));
break;
case 1: // Name, type select.
$form['id'] = array('#type' => 'hidden', '#value' => $form_values['id']);
$form['name'] = array('#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => isset($form_values['name']) ? $form_values['name'] : '',
'#validate' => array('uc_pngquote_element_validate' => array()),
//'#required' => true,
);
$form['type'] = array('#type' => 'select',
'#title' => t('Scope'),
'#options' => array('anywhere' => 'Anywhere', 'code' => uc_get_field_name('postal_code'), 'zone' => uc_get_field_name('zone'), 'country' => uc_get_field_name('country'), 'region' => 'Region'),
'#default_value' => isset($form_values['type']) ? $form_values['type'] : 'code',
'#validate' => array('uc_pngquote_element_validate' => array()),
//'#required' => true,
);
$form['flat_weight'] = array('#type' => 'hidden', '#value' => $form_values['flat_weight']);
$form['area'] = array('#type' => 'hidden', '#value' => $form_values['area']);
$form['basic_charge'] = array('#type' => 'hidden', '#value' => $form_values['basic_charge']);
$form['rate'] = array('#type' => 'hidden', '#value' => $form_values['rate']);
$form['min_weight'] = array('#type' => 'hidden', '#value' => $form_values['min_weight']);
$form['max_weight'] = array('#type' => 'hidden', '#value' => $form_values['max_weight']);
$form['max_amount'] = array('#type' => 'hidden', '#value' => $form_values['max_amount']);
$form['units'] = array('#type' => 'hidden', '#value' => $form_values['units']);
$form['conditions'] = array('#type' => 'hidden', '#value' => $form_values['conditions']);
$form['cancel'] = array('#type' => 'submit', '#value' => t('Cancel'));
$form['next'] = array('#type' => 'submit', '#value' => t('Next'));
break;
case 2: // Choose area
$form['id'] = array('#type' => 'hidden', '#value' => $form_values['id']);
$form['name'] = array('#type' => 'hidden', '#value' => $form_values['name']);
$form['type'] = array('#type' => 'hidden', '#value' => $form_values['type']);
switch ($form_values['type']){
case 'code':
$form['area'] = array('#type' => 'textfield',
'#title' => t('Area'),
'#default_value' => $form_values['area'],
'#description' => t('Specify shipping rates that are specific to postal code areas.
A "*" may be used as a wild card to set a rate for multiple areas.
Example: In the US, 402* represents all areas from 40200 to 40299.'),
'#size' => 15,
'#validate' => array('uc_pngquote_element_validate' => array()),
//'#required' => true,
);
break;
case 'zone':
$zone = db_fetch_object(db_query("SELECT * FROM {uc_zones} WHERE zone_id = %d", $form_values['area']));
$form['area_country'] = uc_country_select(uc_get_field_name('country'), isset($zone->zone_country_id) ? $zone->zone_country_id : null);
$form['area_zone'] = uc_zone_select(uc_get_field_name('zone'), isset($form_values['area']) ? $form_values['area'] : null, null, isset($_POST['area_country']) ? intval($_POST['area_country']) : $zone->zone_country_id);
$form['area'] = array('#type' => 'hidden', '#value' => $form_values['area']);
break;
case 'country':
$form['area'] = uc_country_select(t('Country'), isset($form_values['area']) ? $form_values['area'] : null);
break;
case 'anywhere':
$form['anywhere'] = array(
'#description' => t("This will apply a rule to all shipping purchases. If there are other rules that are relevant to your shipping purchase, this rule will be disabled.")
);
break;
case 'region':
$mysql = db_query('SELECT * FROM {uc_regions}');
$regions = array();
while($row = db_fetch_array($mysql)) {
$regions[$row['id']] = t($row['name']);
}
$form['area'] = array('#type' => 'select',
'#title' => t('Regions'),
'#options' => $regions,
'#default_value' => $form_values['area'],
'#validate' => array('uc_pngquote_element_validate' => array()),
'#description' => t("Select Region"),
);
break;
}
$form['flat_weight'] = array('#type' => 'hidden', '#value' => $form_values['flat_weight']);
$form['basic_charge'] = array('#type' => 'hidden', '#value' => $form_values['basic_charge']);
$form['rate'] = array('#type' => 'hidden', '#value' => $form_values['rate']);
$form['min_weight'] = array('#type' => 'hidden', '#value' => $form_values['min_weight']);
$form['max_weight'] = array('#type' => 'hidden', '#value' => $form_values['max_weight']);
$form['max_amount'] = array('#type' => 'hidden', '#value' => $form_values['max_amount']);
$form['units'] = array('#type' => 'hidden', '#value' => $form_values['units']);
$form['conditions'] = array('#type' => 'hidden', '#value' => $form_values['conditions']);
$form['back'] = array('#type' => 'submit', '#value' => t('Back'));
$form['next'] = array('#type' => 'submit', '#value' => t('Next'));
break;
case 3: // Amount, etc.?
$form['id'] = array('#type' => 'hidden', '#value' => $form_values['id']);
$form['name'] = array('#type' => 'hidden', '#value' => $form_values['name']);
$form['type'] = array('#type' => 'hidden', '#value' => $form_values['type']);
$form['area'] = array('#type' => 'hidden', '#value' => $form_values['area']);
$form['flat_weight'] = array('#type' => 'select',
'#title' => t('Rule Type'),
'#options' => array('flat' => 'Flat Value', 'weight' => 'Per Weight'),
'#default_value' => isset($form_values['flat_weight']) ? $form_values['flat_weight'] : 'flat',
'#validate' => array('uc_pngquote_element_validate' => array()),
//'#required' => true,
);
$form['units'] = array('#type' => 'select',
'#title' => t('Units'),
'#options' => array('LB' => t('Pounds'), 'G' => t('Grams'),'KG' => t('Kilograms'),'OZ' => t('Ounces'),),
'#default_value' => isset($form_values['units']) ? $form_values['units'] : 'KG',
'#validate' => array('uc_pngquote_element_validate' => array()),
'#description' => t('Weight Unit used by all fields'),
//'#required' => true,
);
$form['basic_charge'] = array('#type' => 'textfield',
'#title' => t('Basic Charge'),
'#description' => t('The basic charge as a currency value. Do not include any currency symbols or commas. Use decimal point as decimal delimiter. Examples: 6.50 or 12'),
'#default_value' => isset($form_values['basic_charge']) ? $form_values['basic_charge'] : '',
'#size' => 15,
'#validate' => array('uc_pngquote_element_validate' => array()),
'#required' => true,
);
$form['rate'] = array('#type' => 'textfield',
'#title' => t('Rate'),
'#description' => t('The shipping rate as a currency value. Do not include any currency symbols or commas. Use decimal point as decimal delimiter. Examples: 6.50 or 12'),
'#default_value' => isset($form_values['rate']) ? $form_values['rate'] : '',
'#size' => 15,
'#validate' => array('uc_pngquote_element_validate' => array()),
'#required' => true,
);
$form['min_weight'] = array('#type' => 'textfield',
'#title' => t('Min. weight'),
'#description' => t('The minimum weight in this price range.'),
'#default_value' => isset($form_values['min_weight']) ? $form_values['min_weight'] : '',
'#size' => 10,
);
$form['max_weight'] = array('#type' => 'textfield',
'#title' => t('Max. weight'),
'#description' => t('The maximum weight in this price range.'),
'#default_value' => isset($form_values['max_weight']) ? $form_values['max_weight'] : '',
'#size' => 10,
);
$form['max_amount'] = array('#type' => 'textfield',
'#title' => t('Max. order price'),
'#description' => t('All orders above this total amount will be shipped for free.'),
'#default_value' => isset($form_values['max_amount']) ? $form_values['max_amount'] : '',
'#size' => 10,
//'#validate' => array('uc_geoshipping_element_validate' => array()),
);
$options = array();
$form['conditions'] = array('#type' => 'textarea',
'#title' => t('Custom conditions'),
'#default_value' => isset($form_values['conditions']) ? $form_values['conditions'] : '',
'#description' => t("For experts only. Enter PHP code that returns true or false, which indicates that this rule applies to an order. Do not include <?php ?> tags. This code is evaluated after the rule matches the customer's address.\nMisusing this field can really mess up your site. DO NOT BE STUPID."),
);
$form['back'] = array('#type' => 'submit', '#value' => t('Back'));
$form['finish'] = array('#type' => 'submit', '#value' => t('Submit'));
break;
}
return $form;
}
function theme_uc_pngquote_form($form){
if ($form['step']['#value'] == 0){
$header = array(t('Name'), t('Scope'), t('Area'), t('Units'), t('Basic Charge'), t('Rate'), t('Min. weight'), t('Max. weight'), t('Max. order price'), t('Rule Type'), array('data' => t('Actions'), 'colspan' => 3));
$rows = array();
$result = db_query("SELECT * FROM {uc_pngquote} ORDER BY area");
while ($rule = db_fetch_object($result)){
switch ($rule->type){
case 'code':
$area = $rule->area;
break;
case 'zone':
$area = uc_get_zone_code($rule->area);
break;
case 'country':
$country = uc_get_country_data(array('country_id' => $rule->area));
$area = $country[0]['country_iso_code_3'];
break;
case 'region':
$mysql = db_query('SELECT name FROM {uc_regions} WHERE id=%d',$rule->area);
$area = db_result($mysql);
break;
}
$rows[] = array($rule->name, $rule->type, $area, $rule->units, $rule->basic_charge, $rule->rate, $rule->min_weight, $rule->max_weight, $rule->max_amount, $rule->flat_weight, l(t('edit'), 'admin/store/settings/quotes/methods/pngquote/edit/'. $rule->id), l(t('copy'), 'admin/store/settings/quotes/methods/pngquote/copy/'. $rule->id), l(t('delete'), 'admin/store/settings/quotes/methods/pngquote/delete/'. $rule->id));
}
$output = theme('table', $header, $rows);
}
$output .= drupal_render($form);
return $output;
}
function uc_pngquote_element_validate($elements){
if ($GLOBALS['form_values']['op'] == t('Submit') || $GLOBALS['form_values']['op'] == t('Next')){
if (empty($elements['#value']) && $elements['#value'] !== '0') {
form_error($elements, t('!name field is required.', array('!name' => $elements['#title'])));
}
}
}
function uc_pngquote_form_submit($form_id, $form_values){
if ($form_values['op'] == t('Cancel')){
drupal_goto('admin/store/settings/quotes/methods/pngquote');
}
if ($form_values['op'] == t('Submit')){
$basic_charge = floatval($form_values['basic_charge']);
$rate = floatval($form_values['rate']);
$max_amount = strlen($form_values['max_amount']) ? $form_values['max_amount']:'null';
$min_weight = strlen($form_values['min_weight']) ? $form_values['min_weight']:'null';
$max_weight = strlen($form_values['max_weight']) ? $form_values['max_weight']:'null';
if (($form_values['id']) != ''){
db_query("UPDATE {uc_pngquote} SET name='%s', units='%s', area='%s', type='%s', basic_charge=%f, rate=%f ,max_amount=%f,"
."min_weight=%f, max_weight=%f, conditions='%s', flat_weight='%s' WHERE id=%d",
$form_values['name'], $form_values['units'], $form_values['area'],
$form_values['type'], $rate, $max_amount, $min_weight, $max_weight,
$form_values['conditions'], $form_values['flat_weight'], $form_values['id']);
}
else{
$next_id = db_next_id('{uc_pngquote}_id');
db_query("INSERT INTO {uc_pngquote} (id, name, units, area, type, basic_charge, rate, max_amount,"
."min_weight, max_weight, conditions, flat_weight) VALUES "
."(%d, '%s', '%s', '%s', '%s', %f, %f, %f, %f, %f, '%s', '%s')",
$next_id, $form_values['name'], $form_values['units'], $form_values['area'],
$form_values['type'], $form_values['basic_charge'], $form_values['rate'], $form_values['max_amount'],
$form_values['min_weight'], $form_values['max_weight'],
$form_values['conditions'], $form_values['flat_weight']);
}
drupal_goto('admin/store/settings/quotes/methods/pngquote'); // workaround #redirect = false for editing geoshipping rules.
}
}
function uc_pngquote_copy($pngquoterate_id){
$rule = db_fetch_array(db_query("SELECT * FROM {uc_pngquote} WHERE id = %d", $pngquoterate_id));
$next_id = db_next_id('{uc_pngquote}_id');
db_query("INSERT INTO {uc_pngquote} (id, name, units, area, type, basic_charge, rate, max_amount,"
."min_weight, max_weight, conditions, flat_weight) VALUES "
."(%d, '%s', '%s', '%s', '%s', %f, %f, %f, %f, %f, '%s', '%s')",
$next_id, $rule['name'], $rule['units'], $rule['area'],
$rule['type'], $rule['basic_charge'], $rule['rate'], $rule['max_amount'],
$rule['min_weight'], $rule['max_weight'],
$rule['conditions'], $rule['flat_weight']);
drupal_goto('admin/store/settings/quotes/methods/pngquote');
}
function uc_pngquote_delete($pngquoterate_id = 0){
if ($pngquoterate_id != 0){
$rule = db_fetch_object(db_query("SELECT * FROM {uc_pngquote} WHERE id = %d", $pngquoterate_id));
$form = array(
'id' => array('#type' => 'value', '#value' => $pngquoterate_id),
);
$output = confirm_form($form, t('Delete !rule?', array('!rule' => $rule->name)), 'admin/store/settings/quotes/methods/pngquote', '', t('Continue'), t('Cancel'));
return $output;
}
else{
drupal_goto('admin/store/settings/quotes/methods/pngquote');
}
}
function uc_pngquote_delete_submit($form_id, $form_values){
if ($form_values['confirm']){
db_query("DELETE FROM {uc_pngquote} WHERE id = %d", $form_values['id']);
}
return 'admin/store/settings/quotes/methods/pngquote';
}
/**
* Implementation of Übercart's hook_shipping_method().
*/
function uc_pngquote_shipping_method(){
$methods = array();
$enabled = variable_get('uc_quote_enabled', array('pngquote' => true, 'order rate' => false));
$weight = variable_get('uc_quote_method_weight', array('weightquote' => 0, 'order rate' => 1));
$methods['pngquote'] = array(
'id' => 'pngquote',
'module' => 'uc_pngquote',
'title' => t('PNG Quote Shipping'),
'enabled' => $enabled['pngquote'],
'quote' => array(
'type' => 'small_package',
'callback' => 'uc_pngquote_quote',
'accessorials' => array(
t('Shipping PNG Quote'),
),
),
'weight' => $weight['weightquote'],
);
return $methods;
}
/******************************************************************************
* Module Functions *
******************************************************************************/
/**
* Standard callback to return a shipping rate via the flat rate method.
*
* @param $products
* The order's products.
* @param $details
* Other order details including a shipping address.
* @return
* A JSON object containing the shipping quote for the order.
*/
//retrive all the rules from the db
function uc_pngquote_get_rules()
{
static $pngquote = array();
$result = db_query("SELECT * FROM {uc_pngquote} ORDER BY area");
while ($rule = db_fetch_object($result)){
$pngquote[] = $rule;
}
return $pngquote;
}
//check areas
function uc_pngquote_match_area($pngquotes, $postal_code, $zone, $country) {
$rules = array();
$any = array();
foreach($pngquotes as $pngquote) {
switch ($pngquote->type) {
case 'code':
$code = rtrim($pngquote->area, '*');
if (strpos($postal_code, $code) == 0) {
$rules[] = $pngquote;
}
break;
case 'zone':
if ($pngquote->area == $zone) {
$rules[] = $pngquote;
}
break;
case 'country':
if ($pngquote->area == $country) {
$rules[] = $pngquote;
}
break;
case 'anywhere':
$any[] = $pngquote;
break;
case 'region':
// Do we have the info from the region table for this area already?
if(!isset($countries[$pngquote->area])) {
// This whole block could be replaced by a single SQL statment IF
// the reiogns table was actually 2 tables... ick! CpILL
$region_countries = db_result(db_query("SELECT countries FROM {uc_regions} WHERE id = %d", $pngquote->area));
$region_country_list = array();
foreach(explode(',', $region_countries) as $country_tupal) {
// 1st part should be the country number
$region_country_list[] = array_shift(explode('|', $country_tupal));
}
$countries[$pngquote->area] = $region_country_list;
}
if(in_array($country, $countries[$pngquote->area])) {
$rules[] = $pngquote;
}
break;
}
}
if(count($rules))
return $rules;
if(count($any)) // Only return 'anywhere' rules if no other rules make it though (I think thats what this is about?). CpILL
return $any;
return false;
}
function uc_pngquote_match_weight($pngquotes, $pkgweight) {
$rules= array();
if($pkgweight > 0 && $pngquotes) {
foreach($pngquotes as $i => $pngquote) {
// normalise all weight values...
$units = $pngquote->units;
$min_weight = _uc_normalise_weight($pngquote->min_weight, $units);
$max_weight = _uc_normalise_weight($pngquote->max_weight, $units);
//$max_amount = _uc_normalise_weight($pngquote->max_amount, $units); // this is actually bad logic
watchdog('debug', '$min_weight: '.$min_weight.' $max_weight: '.$max_weight);
// Check against rules max. value
if ($max_weight and $pkgweight > $max_weight) {
unset($pngquotes[$i]);
continue;
}
// Check against rules min. value
if ($min_weight and $pkgweight < $min_weight) {
unset($pngquotes[$i]);
continue;
}
}
return $pngquotes;
}
else
return array();
}
function uc_pngquote_match_amount($pngquotes, $pkgprice) {
$rules= array();
foreach($pngquotes as $pngquote) {
$max_amount = $pngquote->max_amount;
// If the package price is under the maximum amount
if (empty($max_amount)) {
$rules[] = $pngquote;
} else {
if ($pkgprice < $max_amount) {
$rules[] = $pngquote;
} else {
$pngquote->id = 0;
$pngquote->name = t("Free Shipping");
$pngquote->area ="";
$pngquote->type = "anywhere";
$pngquote->basic_charge = 0;
$pngquote->rate = 0;
$pngquote->min_weight = 0;
$pngquote->max_weight = 0;
$pngquote->max_amount = 0;
$pngquote->units = "G";
$pngquote->conditions = "";
$pngquote->flat_weight = "flat";
$rules[] = $pngquote;
}
}
}
return $rules;
}
/******************************************************************************
* Workflow-ng Hooks *
******************************************************************************/
/**
* Implementation of hook_configuration().
*
* Connect the quote action with the quote event.
*/
function uc_pngquote_configuration() {
$enabled = variable_get('uc_quote_enabled', array('pngquote' => true, 'order_rate' => false));
$configurations = array(
'uc_pngquote_get_quote' => array(
'#label' => t('Shipping quote via pngquote'),
'#event' => 'get_quote_from_pngquote',
'#module' => 'uc_pngquote',
'#active' => $enabled['pngquote'],
),
);
$action = workflow_ng_use_action('uc_quote_action_get_quote', array(
'#label' => t('Fetch a shipping quote'),
));
$configurations['uc_pngquote_get_quote'] = workflow_ng_configure($configurations['uc_pngquote_get_quote'], $action);
return $configurations;
}
/**
* @param $products
* Array of cart contents.
* @param $details
* Order details other than product information.
* @return
* JSON object containing rate, error, and debugging information.
*/
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'];
//get order weight
$pkgweight = 0;
$pkgprice = 0;
foreach($products as $product) {
if($product->weight_units) {
$pkgweight += _uc_normalise_weight($product->weight, $product->weight_units) * $product->qty;
$pkgprice += $product->price * $product->qty;
} else {
drupal_set_message('Product "'.$product->title.'" (SKU: '.$product->model.' ) does not have its weight units set. Shipping quote could not be calculated.', 'error');
return 0;
}
}
$rules = uc_pngquote_get_rules();
//remove all rules that don't apply to the shipping infomration
$rules = uc_pngquote_match_area($rules, $postal_code, $zone, $country);
//remove all the rules that don't apply to the pkgwieght
$rules = uc_pngquote_match_weight($rules, $pkgweight);
// remove all rules that don't apply to the maximum order amount
$rules = uc_pngquote_match_amount($rules, $pkgprice);
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;
// 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;
break;
}
}
$method = uc_pngquote_shipping_method();
$quotes[] = array('rate' => $rate, 'format' => uc_currency_format($rate), 'option_label' => $rule->name);
}
return $quotes;
}
/**
* Normalise all weight messurements to kilograms
*
* before comparing any weight mesurement they should be first pass though this
* function to normalise their value. This happens to covert everyting to 'kg'
* but really it doesn't matter.
*
* Taken from part of the 'uc_ups' module so I hope the converion rations are right!
*/
function _uc_normalise_weight($weight, $units) {
switch (strtolower($units)) {
case 'oz':
return $weight / 16;
case 'lb':
return $weight;
case 'g':
return $weight / 1000 * 2.2;
case 'kg':
return $weight;
}
return $out;
}
function uc_checkout_pane_deliverytype($op, &$arg1, $arg2) {
switch ($op) {
case 'view':
$description = t('Please select how you would like your order delivered from the list below!');
$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')));
// $options = array(
// "Standard" => "Standard test",
// "Express" => "Express trial",
// );
$contents['deliverytype_method'] = array(
'#type' => 'select',
'#title' => t('Select a delivery method type'),
'#options' => drupal_map_assoc($options),
'#default_value' => $arg1->deliverytype['method'],
);
/*
$contents['deliverytype_source'] = array(
'#type' => 'textfield',
'#title' => t('Delivery Type'),
'#description' => t('Select Delivery Type'),
);
*/
return array('description' => $description, 'contents' => $contents);
case 'process':
//if ($arg1->deliverytype['source'] !== t('Standard'))
{
//$arg1->deliverytype['method'] = $arg2['deliverytype_source'];
//$arg1->deliverytype['method'] = $arg2['deliverytype_method'];
$arg1->data['method'];
}
//if ($arg1->lead['source'] == t('Other source')) {
// $arg1->lead['other'] = $arg2['lead_other'];
//}
return TRUE;
case 'review':
//if ($arg1->lead['source'] != t('Standard'))
{
// $review[] = array('title' => t('Shipping and Handling'), 'data' => $arg1->deliverytype['source'] == t('Other source') ? check_plain($arg1->deliverytype['other']) : check_plain($arg1->delivery['source']));
// $review[] = array('title' => t('Shipping and Handling'), 'data' => check_plain($arg1->deliverytype['source']));
$review[] = array('title' => t('Title is OK'), 'data' => $arg1->data['method']);
// $review[] = array('title' => t('Site found through'), 'data' => $arg1->lead['source'] == t('Other source') ? check_plain($arg1->lead['other']) : check_plain($arg1->lead['source']));
// $review[] = array('title' => t('This is OK'), 'data' => ;
}
return $review;
//case 'settings':
// $form['uc_deliverytype_options'] = array(
// '#type' => 'textarea',
// '#title' => t('Lead options'),
// '#description' => t('Enter options one per line for the lead tracking select box.'),
// '#default_value' => variable_get('uc_deliverytype_options', ''),
// );
// return $form;
}
}
**************************************


