PHP Code:
class dlyc {
var $code, $title, $description, $icon, $enabled;
// class constructor
function dlyc() {
global $order;
$this->code = 'dlyc';
$this->title = MODULE_SHIPPING_DLYC_TEXT_TITLE;
$this->description = MODULE_SHIPPING_DLYC_TEXT_DESCRIPTION;
$this->tax_class = MODULE_SHIPPING_DLYC_TAX_CLASS;
$this->tax_basis = MODULE_SHIPPING_DLYC_TAX_BASIS;
$this->sort_order = MODULE_SHIPPING_DLYC_SORT_ORDER;
$this->icon = DIR_WS_IMAGES . 'shipping_dly.gif'; // To remove icon change this line to: $this->icon = '';
$this->enabled = MODULE_SHIPPING_DLYC_STATUS;
// Beg Minimum Order Total required to activate module
$this->min_order = MODULE_SHIPPING_DLYC_MINIMUM_ORDER_TOTAL;
if ( ($order->info['total']) < ($this->min_order) ) {
$this->enabled = false;
}
// End Minimum Order Total required to activate module
if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_DLYC_ZONE > 0) ) {
$check_flag = false;
$check_query = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_DLYC_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
$city = split("[:,]" ,MODULE_SHIPPING_DLYC_CITY);
$zip_up = MODULE_SHIPPING_DLYC_CITY;
$zip_up = strtoupper($zip_up);
$zip_up = str_replace (' ', '', $zip_up);
$city = split (',', $zip_up);
$order->delivery['city'] = ($order->delivery['city']);
while (!$check->EOF) {
if ($check->fields['zone_id'] < 1) {
if ((in_array($order->delivery['city'],$city )) or (MODULE_SHIPPING_DLYC_CITY==''))
$check_flag = true;
break;
} elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
if ((in_array($order->delivery['city'],$city )or (MODULE_SHIPPING_DLYC_CITY=='')))
$check_flag = true;
break;
}
}
if ($check_flag == false) {
$this->enabled = false;
}
}
}
// class methods
function quote($method = '') {
global $order, $cart, $shipping_weight, $shipping_num_boxes;
if (MODULE_SHIPPING_DLYC_MODE == 'price') {
$order_total = $cart;
} else {
$order_total = $shipping_weight;
}
$table_cost = split("[:,]" , MODULE_SHIPPING_DLYC_COST);
$shipping_rate = 0;
$size = sizeof($table_cost);
for ($i=0, $n=$size; $i<$n; $i+=2) {
if ($order_total <= $table_cost[$i]) {
$shipping_rate = $table_cost[$i+1];
break;
}
}
if (MODULE_SHIPPING_DLYC_MODE == 'weight') {
$shipping_rate = $shipping_rate * $shipping_num_boxes;
}
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_DLYC_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_DLYC_TEXT_WAY,
'cost' => $shipping_rate)));
if ($this->tax_class > 0) {
$this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
}
if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
return $this->quotes;
}
function check() {
global $db;
if (!isset($this->_check)) {
$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_DLYC_STATUS'");
$this->_check = $check_query->RecordCount();
}
return $this->_check;
}
function install() {
global $db;
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable City Delivery', 'MODULE_SHIPPING_DLYC_STATUS', 'true', 'Do you want to offer City Delivery?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Delivery Cost Method', 'MODULE_SHIPPING_DLYC_MODE', 'weight', 'The delivery cost is based on the order total or the total weight of the items ordered.', '6', '0', 'zen_cfg_select_option(array(\'weight\', \'price\'), ', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Local Delivery Cost', 'MODULE_SHIPPING_DLYC_COST', '25:8.50,50:5.50,10000:0.00', 'The delivery cost is based on the total cost or weight of items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc. Be aware: The Handling fee will NOT be added.', '6', '0', now())");
$db->Execute("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_DLYC_TAX_CLASS', '0', 'Use the following Tax Class on the Shipping Fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Tax Basis', 'MODULE_SHIPPING_DLYC_TAX_BASIS', 'Shipping', 'On what basis is Shipping Tax calculated. Options are<br />Shipping - Based on customers Shipping Address<br />Billing Based on customers Billing address<br />Store - Based on Store address if Billing/Shipping Zone equals Store zone', '6', '0', 'zen_cfg_select_option(array(\'Shipping\', \'Billing\'), ', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Minimum Order Total', 'MODULE_SHIPPING_DLYC_MINIMUM_ORDER_TOTAL', '0.00', 'What is the Minimum Order Total required for this option to be activated.', '6', '0', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Maximum Local Delivery Distance', 'MODULE_SHIPPING_DLYC_MAX_LOCAL_DISTANCE', '12 Km', 'What is the Maximum Local delivery distance which you will travel to deliver orders. [ ie. 12 Km ]', '6', '0', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('City', 'MODULE_SHIPPING_DLYC_CITY', '', 'Only enable this shipping method for these cities. Separate with comma if several, empty if all.', '6', '0', now())");
$db->Execute("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_DLYC_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_DLYC_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
}
function remove() {
global $db;
$db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
function keys() {
return array('MODULE_SHIPPING_DLYC_STATUS', 'MODULE_SHIPPING_DLYC_MODE', 'MODULE_SHIPPING_DLYC_COST', 'MODULE_SHIPPING_DLYC_TAX_CLASS', 'MODULE_SHIPPING_DLYC_TAX_BASIS', 'MODULE_SHIPPING_DLYC_MINIMUM_ORDER_TOTAL', 'MODULE_SHIPPING_DLYC_MAX_LOCAL_DISTANCE', 'MODULE_SHIPPING_DLYC_CITY', 'MODULE_SHIPPING_DLYC_ZONE', 'MODULE_SHIPPING_DLYC_SORT_ORDER', );
}
}
?>
And this module does install with out error reports so I am not sure whats going on.