PHP Code:
<?php
/*
Courier based on..
$Id: table.php 3 2006-05-27 04:59:07Z user $
osCMax Power E-Commerce
http://oscdox.com
Copyright 2006 osCMax
Released under the GNU General Public License
*/
class KBM {
var $code, $title, $description, $icon, $enabled;
// class constructor
function KBM() {
global $order;
$this->code = 'KBM';
$this->title = 'KBM';
$this->description = 'KBM';
$this->sort_order = MODULE_SHIPPING_KBM_SORT_ORDER;
$this->icon = '';
$this->tax_class = MODULE_SHIPPING_KBM_TAX_CLASS;
$this->enabled = ((MODULE_SHIPPING_KBM_STATUS == 'True') ? true : false);
if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_KBM_ZONE > 0) ) {
$check_flag = false;
$check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_KBM_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
while ($check = tep_db_fetch_array($check_query)) {
if ($check['zone_id'] < 1) {
$check_flag = true;
break;
} elseif ($check['zone_id'] == $order->delivery['zone_id']) {
$check_flag = true;
break;
}
}
if ($check_flag == false) {
$this->enabled = false;
}
}
}
// class methods
function quote($method = '') {
global $order;
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_KBM_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => '<FONT COLOR=FF0000><B>' . MODULE_SHIPPING_KBM_TEXT_WAY . '</B></FONT>',
'cost' => SHIPPING_HANDLING + MODULE_SHIPPING_KBM_COST)));
if ($this->tax_class > 0) {
$this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
}
if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);
return $this->quotes;
}
function check() {
if (!isset($this->_check)) {
$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_KBM_STATUS'");
$this->_check = tep_db_num_rows($check_query);
}
return $this->_check;
}
function install() {
// VF Added the following - specific to KBM
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Customer No', 'MODULE_SHIPPING_KBM_CUSTOMER', ' ', 'The customer number required by KBM Parcel Web Services.', '6', '1', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Contract No', 'MODULE_SHIPPING_KBM_CONTRACT', ' ', 'The contract number required by KBM Parcel Web Services.', '6', '2', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Web service Key (WSID)', 'MODULE_SHIPPING_KBM_KEY', ' ', 'The development or production key (development for testing)', '6', '3', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Web service password', 'MODULE_SHIPPING_KBM_PASSWORD', ' ', 'The password for the key.', '6', '4', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Enable Free Shipping', 'MODULE_SHIPPING_KBM_STATUS', '1', 'Do you want to offer Free shipping?', '6', '5', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Free Shipping Cost', 'MODULE_SHIPPING_KBM_COST', '0.00', 'What is the Shipping cost? The Handling fee will also be added.', '6', '6', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_KBM_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '7', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_KBM_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '8', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_KBM_SORT_ORDER', '0', 'Sort order of display.', '6', '9', now())");
}
function remove() {
$keys = '';
$keys_array = $this->keys();
for ($i=0; $i<sizeof($keys_array); $i++) {
$keys .= "'" . $keys_array[$i] . "',";
}
$keys = substr($keys, 0, -1);
tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in (" . $keys . ")");
}
function keys() {
return array('MODULE_SHIPPING_KBM_CUSTOMER','MODULE_SHIPPING_KBM_CONTRACT','MODULE_SHIPPING_KBM_KEY','MODULE_SHIPPING_KBM_PASSWORD','MODULE_SHIPPING_KBM_STATUS', 'MODULE_SHIPPING_KBM_COST', 'MODULE_SHIPPING_KBM_TAX_CLASS', 'MODULE_SHIPPING_KBM_ZONE', 'MODULE_SHIPPING_KBM_SORT_ORDER'');
}
}
?>
Bookmarks