Can you review and post what you are using in the 3 modules, and be sure that the code you are looking at is what is on the server ...
I want to ensure we are on the same page in fixing this last issue ...
Linda McGrath
If you have to think ... you haven't been zenned ...
Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!
Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here
Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!
Here the 3 modules, actually I am running on my local test Xampp server. Do you need me to upload to my live server?
1. singpost - show when cart without cat #20
PHP Code:<?php
/**
* @package shippingMethod
* @copyright Copyright 2003-2010 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: singpost.php 2010-08-16 11:20:16Z totalsam $
* @modifications for allowing multiple zones rates modules to be used on one store
*/
class singpost {
var $code, $title, $description, $enabled, $num_singpost;
// class constructor
function singpost() {
$this->code = 'singpost';
$this->title = MODULE_SHIPPING_SINGPOST_TEXT_TITLE;
$this->description = MODULE_SHIPPING_SINGPOST_TEXT_DESCRIPTION;
$this->sort_order = MODULE_SHIPPING_SINGPOST_SORT_ORDER;
$this->icon = '';
$this->tax_class = MODULE_SHIPPING_SINGPOST_TAX_CLASS;
$this->tax_basis = MODULE_SHIPPING_SINGPOST_TAX_BASIS;
// disable only when entire cart is free shipping
if (zen_get_shipping_enabled($this->code)) {
$this->enabled = ((MODULE_SHIPPING_SINGPOST_STATUS == 'True') ? true : false);
}
// bof: disable for these master_categories_id
if (IS_ADMIN_FLAG == false) {
// check master_categories_id add one line per master_categories_id
$chk_cat = 0;
$chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','20');
if ($chk_cat > 0) {
$this->enabled = false;
}
}
// eof: disable for these master_categories_id
// CUSTOMIZE THIS SETTING FOR THE NUMBER OF SINGPOST NEEDED
$this->num_singpost = 4;
if (IS_ADMIN_FLAG === true) {
// build in admin only additional singpost if missing in the configuration table due to customization of default $this->num_singpost = 3
global $db;
for ($i = 1; $i <= $this->num_singpost; $i++) {
$check = $db->Execute("select * from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_SINGPOST_COUNTRIES_" . $i . "'");
if ($this->enabled && $check->EOF) {
$default_countries = '';
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Zone " . $i ." Countries', 'MODULE_SHIPPING_SINGPOST_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $i . ".<br />Set as 00 to indicate all two character ISO country codes that are not specifically defined.', '6', '0', 'zen_cfg_textarea(', 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 ('Zone " . $i ." Shipping Table', 'MODULE_SHIPPING_SINGPOST_COST_" . $i ."', '3:8.50,7:10.50,99:20.00', 'Shipping rates to Zone " . $i . " destinations based on a group of maximum order weights/prices. Example: 3:8.50,7:10.50,... Weight/Price less than or equal to 3 would cost 8.50 for Zone " . $i . " destinations.<br />You can end the last amount as 10000:7% to charge 7% of the Order Total', '6', '0', 'zen_cfg_textarea(', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone " . $i ." Handling Fee', 'MODULE_SHIPPING_SINGPOST_HANDLING_" . $i."', '0', 'Handling Fee for this shipping zone', '6', '0', 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 ('Handling Per Order or Per Box Zone " . $i . " (when by weight)' , 'MODULE_SHIPPING_SINGPOST_HANDLING_METHOD_" . $i."', 'Order', 'Do you want to charge Handling Fee Per Order or Per Box?', '6', '0', 'zen_cfg_select_option(array(\'Order\', \'Box\'), ', now())");
}
}
} // build in admin only
if ($this->enabled) {
global $db;
for ($i = 1; $i <= $this->num_singpost; $i++) {
// check MODULE_SHIPPING_TABLE_HANDLING_METHOD is in
$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_SINGPOST_HANDLING_METHOD_" . $i . "'");
if ($check_query->EOF) {
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Handling Per Order or Per Box Zone " . $i . " (when by weight)' , 'MODULE_SHIPPING_SINGPOST_HANDLING_METHOD_" . $i."', 'Order', 'Do you want to charge Handling Fee Per Order or Per Box?', '6', '0', 'zen_cfg_select_option(array(\'Order\', \'Box\'), ', now())");
}
}
}
}
// class methods
function quote($method = '') {
global $order, $shipping_weight, $shipping_num_boxes, $total_count;
$dest_country = $order->delivery['country']['iso_code_2'];
$dest_zone = 0;
$error = false;
$order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;
for ($i=1; $i<=$this->num_singpost; $i++) {
$countries_table = constant('MODULE_SHIPPING_SINGPOST_COUNTRIES_' . $i);
$countries_table = strtoupper(str_replace(' ', '', $countries_table));
$country_singpost = preg_split("/[,]/", $countries_table);
if (in_array($dest_country, $country_singpost)) {
$dest_zone = $i;
break;
}
if (in_array('00', $country_singpost)) {
$dest_zone = $i;
break;
}
}
if ($dest_zone == 0) {
$error = true;
} else {
$shipping = -1;
$singpost_cost = constant('MODULE_SHIPPING_SINGPOST_COST_' . $dest_zone);
$singpost_table = preg_split("/[:,]/" , $singpost_cost);
$size = sizeof($singpost_table);
$done = false;
for ($i=0; $i<$size; $i+=2) {
switch (MODULE_SHIPPING_SINGPOST_METHOD) {
case (MODULE_SHIPPING_SINGPOST_METHOD == 'Weight'):
if (round($shipping_weight,9) <= $singpost_table[$i]) {
$shipping = $singpost_table[$i+1];
switch (SHIPPING_BOX_WEIGHT_DISPLAY) {
case (0):
$show_box_weight = '';
break;
case (1):
$show_box_weight = ' (' . $shipping_num_boxes . ' ' . TEXT_SHIPPING_BOXES . ')';
break;
case (2):
$show_box_weight = ' (' . number_format($shipping_weight * $shipping_num_boxes,2) . MODULE_SHIPPING_SINGPOST_TEXT_UNITS . ')';
break;
default:
$show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($shipping_weight,2) . MODULE_SHIPPING_SINGPOST_TEXT_UNITS . ')';
break;
}
// $shipping_method = MODULE_SHIPPING_SINGPOST_TEXT_WAY . ' ' . $dest_country . (SHIPPING_BOX_WEIGHT_DISPLAY >= 2 ? ' : ' . $shipping_weight . ' ' . MODULE_SHIPPING_SINGPOST_TEXT_UNITS : '');
$shipping_method = MODULE_SHIPPING_SINGPOST_TEXT_WAY . ' ' . $dest_country . $show_box_weight;
$done = true;
if (strstr($singpost_table[$i+1], '%')) {
$shipping = ($singpost_table[$i+1]/100) * $order_total_amount;
} else {
$shipping = $singpost_table[$i+1];
}
break;
}
break;
case (MODULE_SHIPPING_SINGPOST_METHOD == 'Price'):
// shipping adjustment
if (($_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices()) <= $singpost_table[$i]) {
$shipping = $singpost_table[$i+1];
$shipping_method = MODULE_SHIPPING_SINGPOST_TEXT_WAY . ' ' . $dest_country;
if (strstr($singpost_table[$i+1], '%')) {
$shipping = ($singpost_table[$i+1]/100) * $order_total_amount;
} else {
$shipping = $singpost_table[$i+1];
}
$done = true;
break;
}
break;
case (MODULE_SHIPPING_SINGPOST_METHOD == 'Item'):
// shipping adjustment
if (($total_count - $_SESSION['cart']->free_shipping_items()) <= $singpost_table[$i]) {
$shipping = $singpost_table[$i+1];
$shipping_method = MODULE_SHIPPING_SINGPOST_TEXT_WAY . ' ' . $dest_country;
$done = true;
if (strstr($singpost_table[$i+1], '%')) {
$shipping = ($singpost_table[$i+1]/100) * $order_total_amount;
} else {
$shipping = $singpost_table[$i+1];
}
break;
}
break;
}
if ($done == true) {
break;
}
}
if ($shipping == -1) {
$shipping_cost = 0;
$shipping_method = MODULE_SHIPPING_SINGPOST_UNDEFINED_RATE;
} else {
switch (MODULE_SHIPPING_SINGPOST_METHOD) {
case (MODULE_SHIPPING_SINGPOST_METHOD == 'Weight'):
// charge per box when done by Weight
// Handling fee per box or order
if (constant('MODULE_SHIPPING_SINGPOST_HANDLING_METHOD_' . $dest_zone) == 'Box') {
$shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_SINGPOST_HANDLING_' . $dest_zone) * $shipping_num_boxes;
} else {
$shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_SINGPOST_HANDLING_' . $dest_zone);
}
break;
case (MODULE_SHIPPING_SINGPOST_METHOD == 'Price'):
// don't charge per box when done by Price
$shipping_cost = ($shipping) + constant('MODULE_SHIPPING_SINGPOST_HANDLING_' . $dest_zone);
break;
case (MODULE_SHIPPING_SINGPOST_METHOD == 'Item'):
// don't charge per box when done by Item
$shipping_cost = ($shipping) + constant('MODULE_SHIPPING_SINGPOST_HANDLING_' . $dest_zone);
break;
}
}
}
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_SINGPOST_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => $shipping_method,
'cost' => $shipping_cost)));
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);
if (strstr(MODULE_SHIPPING_SINGPOST_SKIPPED, $dest_country)) {
// don't show anything for this country
$this->quotes = array();
} else {
if ($error == true) $this->quotes['error'] = MODULE_SHIPPING_SINGPOST_INVALID_ZONE;
}
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_SINGPOST_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 Zones Method', 'MODULE_SHIPPING_SINGPOST_STATUS', 'True', 'Do you want to offer zone rate shipping?', '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 ('Calculation Method', 'MODULE_SHIPPING_SINGPOST_METHOD', 'Weight', 'Calculate cost based on Weight, Price or Item?', '6', '0', 'zen_cfg_select_option(array(\'Weight\', \'Price\', \'Item\'), ', 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_SINGPOST_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_SINGPOST_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\', \'Store\'), ', 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_SINGPOST_SORT_ORDER', '0', 'Sort order of display.', '6', '0', 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 ('Skip Countries, use a comma separated list of the two character ISO country codes', 'MODULE_SHIPPING_SINGPOST_SKIPPED', '', 'Disable for the following Countries:', '6', '0', 'zen_cfg_textarea(', now())");
for ($i = 1; $i <= $this->num_singpost; $i++) {
$default_countries = '';
if ($i == 1) {
$default_countries = 'US,CA';
}
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Zone " . $i ." Countries', 'MODULE_SHIPPING_SINGPOST_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $i . ".<br />Set as 00 to indicate all two character ISO country codes that are not specifically defined.', '6', '0', 'zen_cfg_textarea(', 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 ('Zone " . $i ." Shipping Table', 'MODULE_SHIPPING_SINGPOST_COST_" . $i ."', '3:8.50,7:10.50,99:20.00', 'Shipping rates to Zone " . $i . " destinations based on a group of maximum order weights/prices. Example: 3:8.50,7:10.50,... Weight/Price less than or equal to 3 would cost 8.50 for Zone " . $i . " destinations.<br />You can also use percentage amounts, such 25:8.50,35:5%,40:9.50,10000:7% to charge a percentage value of the Order Total', '6', '0', 'zen_cfg_textarea(', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone " . $i ." Handling Fee', 'MODULE_SHIPPING_SINGPOST_HANDLING_" . $i."', '0', 'Handling Fee for this shipping zone', '6', '0', 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 ('Handling Per Order or Per Box Zone " . $i . " (when by weight)' , 'MODULE_SHIPPING_SINGPOST_HANDLING_METHOD_" . $i."', 'Order', 'Do you want to charge Handling Fee Per Order or Per Box?', '6', '0', 'zen_cfg_select_option(array(\'Order\', \'Box\'), ', now())");
}
}
function remove() {
global $db;
$db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key like 'MODULE\_SHIPPING\_SINGPOST\_%'");
}
function keys() {
$keys = array('MODULE_SHIPPING_SINGPOST_STATUS', 'MODULE_SHIPPING_SINGPOST_METHOD', 'MODULE_SHIPPING_SINGPOST_TAX_CLASS', 'MODULE_SHIPPING_SINGPOST_TAX_BASIS', 'MODULE_SHIPPING_SINGPOST_SORT_ORDER', 'MODULE_SHIPPING_SINGPOST_SKIPPED');
for ($i=1; $i<=$this->num_singpost; $i++) {
$keys[] = 'MODULE_SHIPPING_SINGPOST_COUNTRIES_' . $i;
$keys[] = 'MODULE_SHIPPING_SINGPOST_COST_' . $i;
$keys[] = 'MODULE_SHIPPING_SINGPOST_HANDLING_' . $i;
$keys[] = 'MODULE_SHIPPING_SINGPOST_HANDLING_METHOD_' . $i;
}
return $keys;
}
}
?>
2. pos_malaysia - show when cart have only cat #20
PHP Code:<?php
/**
* @package shippingMethod
* @copyright Copyright 2003-2010 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: pos_malaysia.php 2010-08-16 11:20:16Z totalsam $
* @modifications for allowing multiple zones rates modules to be used on one store
*/
class pos_malaysia {
var $code, $title, $description, $enabled, $num_pos_malaysia;
// class constructor
function pos_malaysia() {
$this->code = 'pos_malaysia';
$this->title = MODULE_SHIPPING_POS_MALAYSIA_TEXT_TITLE;
$this->description = MODULE_SHIPPING_POS_MALAYSIA_TEXT_DESCRIPTION;
$this->sort_order = MODULE_SHIPPING_POS_MALAYSIA_SORT_ORDER;
$this->icon = '';
$this->tax_class = MODULE_SHIPPING_POS_MALAYSIA_TAX_CLASS;
$this->tax_basis = MODULE_SHIPPING_POS_MALAYSIA_TAX_BASIS;
// disable only when entire cart is free shipping
if (zen_get_shipping_enabled($this->code)) {
$this->enabled = ((MODULE_SHIPPING_POS_MALAYSIA_STATUS == 'True') ? true : false);
}
// bof: disable for these master_categories_id
if (IS_ADMIN_FLAG == false) {
// check master_categories_id add one line per master_categories_id
$chk_cat = 0;
$chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','20');
if ($chk_cat > 0 && $chk_cat != $_SESSION['cart']->count_contents()) {
$this->enabled = false;
}
}
// eof: disable for these master_categories_id
// CUSTOMIZE THIS SETTING FOR THE NUMBER OF POS_MALAYSIA NEEDED
$this->num_pos_malaysia = 6;
if (IS_ADMIN_FLAG === true) {
// build in admin only additional pos_malaysia if missing in the configuration table due to customization of default $this->num_pos_malaysia = 3
global $db;
for ($i = 1; $i <= $this->num_pos_malaysia; $i++) {
$check = $db->Execute("select * from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_POS_MALAYSIA_COUNTRIES_" . $i . "'");
if ($this->enabled && $check->EOF) {
$default_countries = '';
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Zone " . $i ." Countries', 'MODULE_SHIPPING_POS_MALAYSIA_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $i . ".<br />Set as 00 to indicate all two character ISO country codes that are not specifically defined.', '6', '0', 'zen_cfg_textarea(', 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 ('Zone " . $i ." Shipping Table', 'MODULE_SHIPPING_POS_MALAYSIA_COST_" . $i ."', '3:8.50,7:10.50,99:20.00', 'Shipping rates to Zone " . $i . " destinations based on a group of maximum order weights/prices. Example: 3:8.50,7:10.50,... Weight/Price less than or equal to 3 would cost 8.50 for Zone " . $i . " destinations.<br />You can end the last amount as 10000:7% to charge 7% of the Order Total', '6', '0', 'zen_cfg_textarea(', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone " . $i ." Handling Fee', 'MODULE_SHIPPING_POS_MALAYSIA_HANDLING_" . $i."', '0', 'Handling Fee for this shipping zone', '6', '0', 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 ('Handling Per Order or Per Box Zone " . $i . " (when by weight)' , 'MODULE_SHIPPING_POS_MALAYSIA_HANDLING_METHOD_" . $i."', 'Order', 'Do you want to charge Handling Fee Per Order or Per Box?', '6', '0', 'zen_cfg_select_option(array(\'Order\', \'Box\'), ', now())");
}
}
} // build in admin only
if ($this->enabled) {
global $db;
for ($i = 1; $i <= $this->num_pos_malaysia; $i++) {
// check MODULE_SHIPPING_TABLE_HANDLING_METHOD is in
$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_POS_MALAYSIA_HANDLING_METHOD_" . $i . "'");
if ($check_query->EOF) {
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Handling Per Order or Per Box Zone " . $i . " (when by weight)' , 'MODULE_SHIPPING_POS_MALAYSIA_HANDLING_METHOD_" . $i."', 'Order', 'Do you want to charge Handling Fee Per Order or Per Box?', '6', '0', 'zen_cfg_select_option(array(\'Order\', \'Box\'), ', now())");
}
}
}
}
// class methods
function quote($method = '') {
global $order, $shipping_weight, $shipping_num_boxes, $total_count;
$dest_country = $order->delivery['country']['iso_code_2'];
$dest_zone = 0;
$error = false;
$order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;
for ($i=1; $i<=$this->num_pos_malaysia; $i++) {
$countries_table = constant('MODULE_SHIPPING_POS_MALAYSIA_COUNTRIES_' . $i);
$countries_table = strtoupper(str_replace(' ', '', $countries_table));
$country_pos_malaysia = preg_split("/[,]/", $countries_table);
if (in_array($dest_country, $country_pos_malaysia)) {
$dest_zone = $i;
break;
}
if (in_array('00', $country_pos_malaysia)) {
$dest_zone = $i;
break;
}
}
if ($dest_zone == 0) {
$error = true;
} else {
$shipping = -1;
$pos_malaysia_cost = constant('MODULE_SHIPPING_POS_MALAYSIA_COST_' . $dest_zone);
$pos_malaysia_table = preg_split("/[:,]/" , $pos_malaysia_cost);
$size = sizeof($pos_malaysia_table);
$done = false;
for ($i=0; $i<$size; $i+=2) {
switch (MODULE_SHIPPING_POS_MALAYSIA_METHOD) {
case (MODULE_SHIPPING_POS_MALAYSIA_METHOD == 'Weight'):
if (round($shipping_weight,9) <= $pos_malaysia_table[$i]) {
$shipping = $pos_malaysia_table[$i+1];
switch (SHIPPING_BOX_WEIGHT_DISPLAY) {
case (0):
$show_box_weight = '';
break;
case (1):
$show_box_weight = ' (' . $shipping_num_boxes . ' ' . TEXT_SHIPPING_BOXES . ')';
break;
case (2):
$show_box_weight = ' (' . number_format($shipping_weight * $shipping_num_boxes,2) . MODULE_SHIPPING_POS_MALAYSIA_TEXT_UNITS . ')';
break;
default:
$show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($shipping_weight,2) . MODULE_SHIPPING_POS_MALAYSIA_TEXT_UNITS . ')';
break;
}
// $shipping_method = MODULE_SHIPPING_POS_MALAYSIA_TEXT_WAY . ' ' . $dest_country . (SHIPPING_BOX_WEIGHT_DISPLAY >= 2 ? ' : ' . $shipping_weight . ' ' . MODULE_SHIPPING_POS_MALAYSIA_TEXT_UNITS : '');
$shipping_method = MODULE_SHIPPING_POS_MALAYSIA_TEXT_WAY . ' ' . $dest_country . $show_box_weight;
$done = true;
if (strstr($pos_malaysia_table[$i+1], '%')) {
$shipping = ($pos_malaysia_table[$i+1]/100) * $order_total_amount;
} else {
$shipping = $pos_malaysia_table[$i+1];
}
break;
}
break;
case (MODULE_SHIPPING_POS_MALAYSIA_METHOD == 'Price'):
// shipping adjustment
if (($_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices()) <= $pos_malaysia_table[$i]) {
$shipping = $pos_malaysia_table[$i+1];
$shipping_method = MODULE_SHIPPING_POS_MALAYSIA_TEXT_WAY . ' ' . $dest_country;
if (strstr($pos_malaysia_table[$i+1], '%')) {
$shipping = ($pos_malaysia_table[$i+1]/100) * $order_total_amount;
} else {
$shipping = $pos_malaysia_table[$i+1];
}
$done = true;
break;
}
break;
case (MODULE_SHIPPING_POS_MALAYSIA_METHOD == 'Item'):
// shipping adjustment
if (($total_count - $_SESSION['cart']->free_shipping_items()) <= $pos_malaysia_table[$i]) {
$shipping = $pos_malaysia_table[$i+1];
$shipping_method = MODULE_SHIPPING_POS_MALAYSIA_TEXT_WAY . ' ' . $dest_country;
$done = true;
if (strstr($pos_malaysia_table[$i+1], '%')) {
$shipping = ($pos_malaysia_table[$i+1]/100) * $order_total_amount;
} else {
$shipping = $pos_malaysia_table[$i+1];
}
break;
}
break;
}
if ($done == true) {
break;
}
}
if ($shipping == -1) {
$shipping_cost = 0;
$shipping_method = MODULE_SHIPPING_POS_MALAYSIA_UNDEFINED_RATE;
} else {
switch (MODULE_SHIPPING_POS_MALAYSIA_METHOD) {
case (MODULE_SHIPPING_POS_MALAYSIA_METHOD == 'Weight'):
// charge per box when done by Weight
// Handling fee per box or order
if (constant('MODULE_SHIPPING_POS_MALAYSIA_HANDLING_METHOD_' . $dest_zone) == 'Box') {
$shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_POS_MALAYSIA_HANDLING_' . $dest_zone) * $shipping_num_boxes;
} else {
$shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_POS_MALAYSIA_HANDLING_' . $dest_zone);
}
break;
case (MODULE_SHIPPING_POS_MALAYSIA_METHOD == 'Price'):
// don't charge per box when done by Price
$shipping_cost = ($shipping) + constant('MODULE_SHIPPING_POS_MALAYSIA_HANDLING_' . $dest_zone);
break;
case (MODULE_SHIPPING_POS_MALAYSIA_METHOD == 'Item'):
// don't charge per box when done by Item
$shipping_cost = ($shipping) + constant('MODULE_SHIPPING_POS_MALAYSIA_HANDLING_' . $dest_zone);
break;
}
}
}
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_POS_MALAYSIA_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => $shipping_method,
'cost' => $shipping_cost)));
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);
if (strstr(MODULE_SHIPPING_POS_MALAYSIA_SKIPPED, $dest_country)) {
// don't show anything for this country
$this->quotes = array();
} else {
if ($error == true) $this->quotes['error'] = MODULE_SHIPPING_POS_MALAYSIA_INVALID_ZONE;
}
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_POS_MALAYSIA_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 Zones Method', 'MODULE_SHIPPING_POS_MALAYSIA_STATUS', 'True', 'Do you want to offer zone rate shipping?', '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 ('Calculation Method', 'MODULE_SHIPPING_POS_MALAYSIA_METHOD', 'Weight', 'Calculate cost based on Weight, Price or Item?', '6', '0', 'zen_cfg_select_option(array(\'Weight\', \'Price\', \'Item\'), ', 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_POS_MALAYSIA_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_POS_MALAYSIA_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\', \'Store\'), ', 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_POS_MALAYSIA_SORT_ORDER', '0', 'Sort order of display.', '6', '0', 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 ('Skip Countries, use a comma separated list of the two character ISO country codes', 'MODULE_SHIPPING_POS_MALAYSIA_SKIPPED', '', 'Disable for the following Countries:', '6', '0', 'zen_cfg_textarea(', now())");
for ($i = 1; $i <= $this->num_pos_malaysia; $i++) {
$default_countries = '';
if ($i == 1) {
$default_countries = 'US,CA';
}
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Zone " . $i ." Countries', 'MODULE_SHIPPING_POS_MALAYSIA_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $i . ".<br />Set as 00 to indicate all two character ISO country codes that are not specifically defined.', '6', '0', 'zen_cfg_textarea(', 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 ('Zone " . $i ." Shipping Table', 'MODULE_SHIPPING_POS_MALAYSIA_COST_" . $i ."', '3:8.50,7:10.50,99:20.00', 'Shipping rates to Zone " . $i . " destinations based on a group of maximum order weights/prices. Example: 3:8.50,7:10.50,... Weight/Price less than or equal to 3 would cost 8.50 for Zone " . $i . " destinations.<br />You can also use percentage amounts, such 25:8.50,35:5%,40:9.50,10000:7% to charge a percentage value of the Order Total', '6', '0', 'zen_cfg_textarea(', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone " . $i ." Handling Fee', 'MODULE_SHIPPING_POS_MALAYSIA_HANDLING_" . $i."', '0', 'Handling Fee for this shipping zone', '6', '0', 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 ('Handling Per Order or Per Box Zone " . $i . " (when by weight)' , 'MODULE_SHIPPING_POS_MALAYSIA_HANDLING_METHOD_" . $i."', 'Order', 'Do you want to charge Handling Fee Per Order or Per Box?', '6', '0', 'zen_cfg_select_option(array(\'Order\', \'Box\'), ', now())");
}
}
function remove() {
global $db;
$db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key like 'MODULE\_SHIPPING\_POS_MALAYSIA\_%'");
}
function keys() {
$keys = array('MODULE_SHIPPING_POS_MALAYSIA_STATUS', 'MODULE_SHIPPING_POS_MALAYSIA_METHOD', 'MODULE_SHIPPING_POS_MALAYSIA_TAX_CLASS', 'MODULE_SHIPPING_POS_MALAYSIA_TAX_BASIS', 'MODULE_SHIPPING_POS_MALAYSIA_SORT_ORDER', 'MODULE_SHIPPING_POS_MALAYSIA_SKIPPED');
for ($i=1; $i<=$this->num_pos_malaysia; $i++) {
$keys[] = 'MODULE_SHIPPING_POS_MALAYSIA_COUNTRIES_' . $i;
$keys[] = 'MODULE_SHIPPING_POS_MALAYSIA_COST_' . $i;
$keys[] = 'MODULE_SHIPPING_POS_MALAYSIA_HANDLING_' . $i;
$keys[] = 'MODULE_SHIPPING_POS_MALAYSIA_HANDLING_METHOD_' . $i;
}
return $keys;
}
}
?>
3. singpost_plus_posmalaysia - show when cat #20 plus any other cat
PHP Code:<?php
/**
* @package shippingMethod
* @copyright Copyright 2003-2010 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: singpost_plus_posmalaysia.php 2010-08-16 11:20:16Z totalsam $
* @modifications for allowing multiple zones rates modules to be used on one store
*/
class singpost_plus_posmalaysia {
var $code, $title, $description, $enabled, $num_singpost_plus_posmalaysia;
// class constructor
function singpost_plus_posmalaysia() {
$this->code = 'singpost_plus_posmalaysia';
$this->title = MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_TEXT_TITLE;
$this->description = MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_TEXT_DESCRIPTION;
$this->sort_order = MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_SORT_ORDER;
$this->icon = '';
$this->tax_class = MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_TAX_CLASS;
$this->tax_basis = MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_TAX_BASIS;
// disable only when entire cart is free shipping
if (zen_get_shipping_enabled($this->code)) {
$this->enabled = ((MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_STATUS == 'True') ? true : false);
}
// bof: enable for mixed cart where cat #20 must be present plus any other cat
global $db, $cart;
if (IS_ADMIN_FLAG == false) {
// check master_categories_id add one line per master_categories_id
$chk_cat = 0;
$chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','20');
if ($chk_cat > 0 && $chk_cat == $_SESSION['cart']->count_contents()) {
$this->enabled = false;
}
}
// CUSTOMIZE THIS SETTING FOR THE NUMBER OF SINGPOST_PLUS_POSMALAYSIA NEEDED
$this->num_singpost_plus_posmalaysia = 10;
if (IS_ADMIN_FLAG === true) {
// build in admin only additional singpost_plus_posmalaysia if missing in the configuration table due to customization of default $this->num_singpost_plus_posmalaysia = 3
global $db;
for ($i = 1; $i <= $this->num_singpost_plus_posmalaysia; $i++) {
$check = $db->Execute("select * from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_COUNTRIES_" . $i . "'");
if ($this->enabled && $check->EOF) {
$default_countries = '';
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Zone " . $i ." Countries', 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $i . ".<br />Set as 00 to indicate all two character ISO country codes that are not specifically defined.', '6', '0', 'zen_cfg_textarea(', 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 ('Zone " . $i ." Shipping Table', 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_COST_" . $i ."', '3:8.50,7:10.50,99:20.00', 'Shipping rates to Zone " . $i . " destinations based on a group of maximum order weights/prices. Example: 3:8.50,7:10.50,... Weight/Price less than or equal to 3 would cost 8.50 for Zone " . $i . " destinations.<br />You can end the last amount as 10000:7% to charge 7% of the Order Total', '6', '0', 'zen_cfg_textarea(', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone " . $i ." Handling Fee', 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_HANDLING_" . $i."', '0', 'Handling Fee for this shipping zone', '6', '0', 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 ('Handling Per Order or Per Box Zone " . $i . " (when by weight)' , 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_HANDLING_METHOD_" . $i."', 'Order', 'Do you want to charge Handling Fee Per Order or Per Box?', '6', '0', 'zen_cfg_select_option(array(\'Order\', \'Box\'), ', now())");
}
}
} // build in admin only
if ($this->enabled) {
global $db;
for ($i = 1; $i <= $this->num_singpost_plus_posmalaysia; $i++) {
// check MODULE_SHIPPING_TABLE_HANDLING_METHOD is in
$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_HANDLING_METHOD_" . $i . "'");
if ($check_query->EOF) {
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Handling Per Order or Per Box Zone " . $i . " (when by weight)' , 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_HANDLING_METHOD_" . $i."', 'Order', 'Do you want to charge Handling Fee Per Order or Per Box?', '6', '0', 'zen_cfg_select_option(array(\'Order\', \'Box\'), ', now())");
}
}
}
}
// class methods
function quote($method = '') {
global $order, $shipping_weight, $shipping_num_boxes, $total_count;
$dest_country = $order->delivery['country']['iso_code_2'];
$dest_zone = 0;
$error = false;
$order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;
for ($i=1; $i<=$this->num_singpost_plus_posmalaysia; $i++) {
$countries_table = constant('MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_COUNTRIES_' . $i);
$countries_table = strtoupper(str_replace(' ', '', $countries_table));
$country_singpost_plus_posmalaysia = preg_split("/[,]/", $countries_table);
if (in_array($dest_country, $country_singpost_plus_posmalaysia)) {
$dest_zone = $i;
break;
}
if (in_array('00', $country_singpost_plus_posmalaysia)) {
$dest_zone = $i;
break;
}
}
if ($dest_zone == 0) {
$error = true;
} else {
$shipping = -1;
$singpost_plus_posmalaysia_cost = constant('MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_COST_' . $dest_zone);
$singpost_plus_posmalaysia_table = preg_split("/[:,]/" , $singpost_plus_posmalaysia_cost);
$size = sizeof($singpost_plus_posmalaysia_table);
$done = false;
for ($i=0; $i<$size; $i+=2) {
switch (MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_METHOD) {
case (MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_METHOD == 'Weight'):
if (round($shipping_weight,9) <= $singpost_plus_posmalaysia_table[$i]) {
$shipping = $singpost_plus_posmalaysia_table[$i+1];
switch (SHIPPING_BOX_WEIGHT_DISPLAY) {
case (0):
$show_box_weight = '';
break;
case (1):
$show_box_weight = ' (' . $shipping_num_boxes . ' ' . TEXT_SHIPPING_BOXES . ')';
break;
case (2):
$show_box_weight = ' (' . number_format($shipping_weight * $shipping_num_boxes,2) . MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_TEXT_UNITS . ')';
break;
default:
$show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($shipping_weight,2) . MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_TEXT_UNITS . ')';
break;
}
// $shipping_method = MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_TEXT_WAY . ' ' . $dest_country . (SHIPPING_BOX_WEIGHT_DISPLAY >= 2 ? ' : ' . $shipping_weight . ' ' . MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_TEXT_UNITS : '');
$shipping_method = MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_TEXT_WAY . ' ' . $dest_country . $show_box_weight;
$done = true;
if (strstr($singpost_plus_posmalaysia_table[$i+1], '%')) {
$shipping = ($singpost_plus_posmalaysia_table[$i+1]/100) * $order_total_amount;
} else {
$shipping = $singpost_plus_posmalaysia_table[$i+1];
}
break;
}
break;
case (MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_METHOD == 'Price'):
// shipping adjustment
if (($_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices()) <= $singpost_plus_posmalaysia_table[$i]) {
$shipping = $singpost_plus_posmalaysia_table[$i+1];
$shipping_method = MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_TEXT_WAY . ' ' . $dest_country;
if (strstr($singpost_plus_posmalaysia_table[$i+1], '%')) {
$shipping = ($singpost_plus_posmalaysia_table[$i+1]/100) * $order_total_amount;
} else {
$shipping = $singpost_plus_posmalaysia_table[$i+1];
}
$done = true;
break;
}
break;
case (MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_METHOD == 'Item'):
// shipping adjustment
if (($total_count - $_SESSION['cart']->free_shipping_items()) <= $singpost_plus_posmalaysia_table[$i]) {
$shipping = $singpost_plus_posmalaysia_table[$i+1];
$shipping_method = MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_TEXT_WAY . ' ' . $dest_country;
$done = true;
if (strstr($singpost_plus_posmalaysia_table[$i+1], '%')) {
$shipping = ($singpost_plus_posmalaysia_table[$i+1]/100) * $order_total_amount;
} else {
$shipping = $singpost_plus_posmalaysia_table[$i+1];
}
break;
}
break;
}
if ($done == true) {
break;
}
}
if ($shipping == -1) {
$shipping_cost = 0;
$shipping_method = MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_UNDEFINED_RATE;
} else {
switch (MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_METHOD) {
case (MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_METHOD == 'Weight'):
// charge per box when done by Weight
// Handling fee per box or order
if (constant('MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_HANDLING_METHOD_' . $dest_zone) == 'Box') {
$shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_HANDLING_' . $dest_zone) * $shipping_num_boxes;
} else {
$shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_HANDLING_' . $dest_zone);
}
break;
case (MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_METHOD == 'Price'):
// don't charge per box when done by Price
$shipping_cost = ($shipping) + constant('MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_HANDLING_' . $dest_zone);
break;
case (MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_METHOD == 'Item'):
// don't charge per box when done by Item
$shipping_cost = ($shipping) + constant('MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_HANDLING_' . $dest_zone);
break;
}
}
}
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => $shipping_method,
'cost' => $shipping_cost)));
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);
if (strstr(MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_SKIPPED, $dest_country)) {
// don't show anything for this country
$this->quotes = array();
} else {
if ($error == true) $this->quotes['error'] = MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_INVALID_ZONE;
}
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_SINGPOST_PLUS_POSMALAYSIA_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 Zones Method', 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_STATUS', 'True', 'Do you want to offer zone rate shipping?', '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 ('Calculation Method', 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_METHOD', 'Weight', 'Calculate cost based on Weight, Price or Item?', '6', '0', 'zen_cfg_select_option(array(\'Weight\', \'Price\', \'Item\'), ', 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_SINGPOST_PLUS_POSMALAYSIA_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_SINGPOST_PLUS_POSMALAYSIA_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\', \'Store\'), ', 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_SINGPOST_PLUS_POSMALAYSIA_SORT_ORDER', '0', 'Sort order of display.', '6', '0', 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 ('Skip Countries, use a comma separated list of the two character ISO country codes', 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_SKIPPED', '', 'Disable for the following Countries:', '6', '0', 'zen_cfg_textarea(', now())");
for ($i = 1; $i <= $this->num_singpost_plus_posmalaysia; $i++) {
$default_countries = '';
if ($i == 1) {
$default_countries = 'US,CA';
}
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Zone " . $i ." Countries', 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $i . ".<br />Set as 00 to indicate all two character ISO country codes that are not specifically defined.', '6', '0', 'zen_cfg_textarea(', 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 ('Zone " . $i ." Shipping Table', 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_COST_" . $i ."', '3:8.50,7:10.50,99:20.00', 'Shipping rates to Zone " . $i . " destinations based on a group of maximum order weights/prices. Example: 3:8.50,7:10.50,... Weight/Price less than or equal to 3 would cost 8.50 for Zone " . $i . " destinations.<br />You can also use percentage amounts, such 25:8.50,35:5%,40:9.50,10000:7% to charge a percentage value of the Order Total', '6', '0', 'zen_cfg_textarea(', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone " . $i ." Handling Fee', 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_HANDLING_" . $i."', '0', 'Handling Fee for this shipping zone', '6', '0', 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 ('Handling Per Order or Per Box Zone " . $i . " (when by weight)' , 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_HANDLING_METHOD_" . $i."', 'Order', 'Do you want to charge Handling Fee Per Order or Per Box?', '6', '0', 'zen_cfg_select_option(array(\'Order\', \'Box\'), ', now())");
}
}
function remove() {
global $db;
$db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key like 'MODULE\_SHIPPING\_SINGPOST_PLUS_POSMALAYSIA\_%'");
}
function keys() {
$keys = array('MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_STATUS', 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_METHOD', 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_TAX_CLASS', 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_TAX_BASIS', 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_SORT_ORDER', 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_SKIPPED');
for ($i=1; $i<=$this->num_singpost_plus_posmalaysia; $i++) {
$keys[] = 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_COUNTRIES_' . $i;
$keys[] = 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_COST_' . $i;
$keys[] = 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_HANDLING_' . $i;
$keys[] = 'MODULE_SHIPPING_SINGPOST_PLUS_POSMALAYSIA_HANDLING_METHOD_' . $i;
}
return $keys;
}
}
?>
Hi Linda, just found another problem. When select pos_malaysia or singpost_plus_posmalaysia for shipping under Step 1 of 3 - Delivery Information, it can't go to Step 2 - choose your payment method but for singpost, is working fine. I have re-install the 2 modules but still the same.
When you go to the Modules ... Shipping ... and click on these 3 shipping methods ... what are the settings that show in the right panel?
Linda McGrath
If you have to think ... you haven't been zenned ...
Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!
Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here
Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!
Hi Linda, here's the setting
1. Singpost
2. Pos MalaysiaPHP Code:Zone Based Rates
Enable Zones Method
True
Calculation Method
Weight
Tax Class
--none--
Tax Basis
Shipping
Sort Order
60
Skip Countries, use a comma separated list of the two character ISO country codes
Zone 1 Countries
BN,MY
Zone 1 Shipping Table
100:2.54,200:3.38,300:4.22,400:5.06,500:5.9,600:6.74,700:7.58,800:8.42,900:9.26,1000:10.1,1100:10.94,1200:11.78,1300:12.62,1400:13.46,1500:14.3,1600:15.14,1700:15.98,1800:16.82,1900:17.66,2000:18.5
Zone 1 Handling Fee
0
Handling Per Order or Per Box Zone 1 (when by weight)
Order
Zone 2 Countries
AS,BD,BT,KH,CN,FJ,PF,GU,HK,IN,ID,KI,KR,LA,MO,MV,MH,FM,MN,BM,NR,NP,NC,MP,PK,PW,PG,PH,PN,WS,SB,LK,TW,TH,TL,TO,TV,VU,VN,WF
Zone 2 Shipping Table
100:4.04,200:6.12,300:8.2,400:10.28,500:12.36,600:14.44,700:16.52,800:18.60,900:20.68,1000:22.76,1100:24.84,1200:26.92,1300:29,1400:31.08,1500:33.16,1600:35.24,1700:37.32,1800:39.4,1900:41.48,2000:43.56
Zone 2 Handling Fee
0
Handling Per Order or Per Box Zone 2 (when by weight)
Order
Zone 3 Countries
AF,AL,DZ,AD,AI,AG,AR,AM,AW,AU,AT,AZ,BS,BH,BB,BY,BY,BE,BZ,BJ,BM,BO,BA,BW,BR,IO,BG,BF,BI,CMCA,CV,KY,CF,TD,CL,CO,KM,CGCR,CU,CY,CZ,DK,DJ,DM,DO,EC,EG,SV,GQ,ER,EE,ET,FK,FO,FI,FR,PF,GA,GM,GE,DE,GH,GI,GR,GL,GD,GT,GN,GW,GY,HT,VA,HN,HU,IS,IR,IQ,IE,IM,IL,IT,JM,JP,JE,JO,KZ,KE,KW,KG,LV,LB,LS,LR,LY,LI,LT,LU,MK,MG,MW,ML,MT,MR,MU,YT,MX,MD,MC,ME,MS,MA,MZ,NA,NL,AN,NZ,NI,NE,NG,NO,OM,PA,PY,PE,PL,PT,PR,QA,RE,RO,RU,RW,SM,ST,SA,SN,RS,SC,SL,SK,SI,SO,ZA,ES,SD,SR,SJ,SZ,SE,CH,SY,TJ,TZ,TG,TT,TN,TR,TM,TC,UG,UA,AE,GB,US,UY,UZ,VE,EH,YE,ZM,ZW
Zone 3 Shipping Table
100:5.08,200:8.00,300:10.92,400:13.84,500:16.76,600:19.68,700:22.60,800:25.52,900:28.44,1000:31.36,1100:34.28,1200:37.2,1300:40.12,1400:43.04,1500:45.96,1600:48.88,1700:51.80,1800:54.72,1900:57.64,2000:60.56
Zone 3 Handling Fee
0
Handling Per Order or Per Box Zone 3 (when by weight)
Order
Zone 4 Countries
SG
Zone 4 Shipping Table
100:2.54,250:2.70,500:3.12,1000:4.00,2000:4.66
Zone 4 Handling Fee
0
Handling Per Order or Per Box Zone 4 (when by weight)
Order
3. Singpost Plus Pos MalaysiaPHP Code:Zone Based Rates
Enable Zones Method
True
Calculation Method
Weight
Tax Class
--none--
Tax Basis
Shipping
Sort Order
80
Skip Countries, use a comma separated list of the two character ISO country codes
Zone 1 Countries
BN,KH,ID,LA,MM,PH,SG,TH,VM
Zone 1 Shipping Table
100:1.23,200:2.4,300:3.57,400:4.74,500:5.91,600:7.08,700:8.25,800:9.42,900:10.59,1000:11.76,1100:12.93,1200:14.1,1300:15.27,1400:16.44,1500:17.61,1600:18.78,1700:19.95,1800:21.12,1900:22.29,2000:23.46
Zone 1 Handling Fee
0
Handling Per Order or Per Box Zone 1 (when by weight)
Order
Zone 2 Countries
AF,BG,BT,CC,CN,HK,II,KN,MH,MV,NR,NP,PK,PP,CE,TW,TL
Zone 2 Shipping Table
100:1.33,200:2.5,300:3.67,400:4.84,500:6.01,600:7.18,700:8.35,800:9.52,900:10.69,1000:11.86,1100:13.03,1200:14.2,1300:15.37,1400:16.54,1500:17.71,1600:18.88,1700:20.05,1800:21.22,1900:22.39,2000:23.56
Zone 2 Handling Fee
0
Handling Per Order or Per Box Zone 2 (when by weight)
Order
Zone 3 Countries
JA,AU,NZ
Zone 3 Shipping Table
100:1.40,200:2.6,300:3.77,400:4.94,500:6.11,600:7.28,700:8.45,800:9.62,900:10.79,1000:11.96,1100:13.13,1200:14.3,1300:15.47,1400:16.64,1500:17.81,1600:18.98,1700:20.15,1800:21.32,1900:22.49,2000:23.66
Zone 3 Handling Fee
0
Handling Per Order or Per Box Zone 3 (when by weight)
Order
Zone 4 Countries
AE,AL,AD,AM,AT,BH,BY,BE,BA,BG,HR,CY,CZ,DK,EG,EE,FO,FI,FR,GE,DE,GI,GB,GR,GL,HU,IS,IE,IR,IQ,IT,JO,KZ,KW,LV,LB,LY,LT,LU,MD,MN,NL,NO,OM,PL,PT,QA,RE,RO,RU,SM,SA,SK,SI,ES,SE,CH,SY,TJ,TR,TM,UA,AE,UZ,YE
Zone 4 Shipping Table
100:1.84,200:3.51,300:5.18,400:6.85,500:8.52,600:10.19,700:11.86,800:13.53,900:15.2,1000:16.87,1100:18.54,1200:20.21,1300:21.88,1400:23.55,1500:25.22,1600:26.89,1700:28.56,1800:30.23,1900:31.9,2000:33.57
Zone 4 Handling Fee
0
Handling Per Order or Per Box Zone 4 (when by weight)
Order
Zone 5 Countries
DZ,AO,AI,AG,AW,AN,AR,BS,BB,BZ,BJ,BM,BO,BW,BR,BF,CM,CA,CV,KY,CF,TD,CL,CO,KM,CG,CR,CU,DJ,DM,DO,SV,GQ,ET,FK,PF,GA,GM,GH,GU,GT,GN,GW,GY,HT,HN,JM,KE,LS,LR,MG,MW,ML,MT,MH,MU,MR,MX,MS,MA,MZ,NA,AN,NI,NE,NG,PA,PY,PE,PR,CG,RW,SH,KN,LC,PM,ST,SN,SC,SL,SO,ZA,SD,SR,SZ,TZ,TG,TO,TT,TC,UG,US,UY,VE,VI,ZM,ZW
Zone 5 Shipping Table
100:2.47,200:4.8,300:7.13,400:9.46,500:11.79,600:14.12,700:16.45,800:18.78,900:21.11,1000:23.44,1100:25.77,1200:28.1,1300:30.43,1400:32.76,1500:35.09,1600:37.42,1700:39.75,1800:42.08,1900:44.41,2000:46.74
Zone 5 Handling Fee
0
Handling Per Order or Per Box Zone 5 (when by weight)
Order
Zone 6 Countries
MY
Zone 6 Shipping Table
500:2.84,1000:3.34,1500:4.34,2000:5.34
Zone 6 Handling Fee
0
Handling Per Order or Per Box Zone 6 (when by weight)
Order
PHP Code:Zone Based Rates
Enable Zones Method
True
Calculation Method
Weight
Tax Class
--none--
Tax Basis
Shipping
Sort Order
100
Skip Countries, use a comma separated list of the two character ISO country codes
Zone 1 Countries
BN,MY,SG
Zone 1 Shipping Table
100:2.54,200:3.38,300:4.22,400:5.06,500:5.9,600:6.74,700:7.58,800:8.42,900:9.26,1000:10.1,1100:10.94,1200:11.78,1300:12.62,1400:13.46,1500:14.3,1600:15.14,1700:15.98,1800:16.82,1900:17.66,2000:18.5
Zone 1 Handling Fee
0
Handling Per Order or Per Box Zone 1 (when by weight)
Order
Zone 2 Countries
AS,BD,BT,KH,CN,FJ,PF,GU,HK,IN,ID,KI,KR,LA,MO,MV,MH,FM,MN,BM,NR,NP,NC,MP,PK,PW,PG,PH,PN,WS,SB,LK,TW,TH,TL,TO,TV,VU,VN,WF
Zone 2 Shipping Table
100:4.04,200:6.12,300:8.2,400:10.28,500:12.36,600:14.44,700:16.52,800:18.60,900:20.68,1000:22.76,1100:24.84,1200:26.92,1300:29,1400:31.08,1500:33.16,1600:35.24,1700:37.32,1800:39.4,1900:41.48,2000:43.56
Zone 2 Handling Fee
0
Handling Per Order or Per Box Zone 2 (when by weight)
Order
Zone 3 Countries
AF,AL,DZ,AD,AI,AG,AR,AM,AW,AU,AT,AZ,BS,BH,BB,BY,BY,BE,BZ,BJ,BM,BO,BA,BW,BR,IO,BG,BF,BI,CMCA,CV,KY,CF,TD,CL,CO,KM,CGCR,CU,CY,CZ,DK,DJ,DM,DO,EC,EG,SV,GQ,ER,EE,ET,FK,FO,FI,FR,PF,GA,GM,GE,DE,GH,GI,GR,GL,GD,GT,GN,GW,GY,HT,VA,HN,HU,IS,IR,IQ,IE,IM,IL,IT,JM,JP,JE,JO,KZ,KE,KW,KG,LV,LB,LS,LR,LY,LI,LT,LU,MK,MG,MW,ML,MT,MR,MU,YT,MX,MD,MC,ME,MS,MA,MZ,NA,NL,AN,NZ,NI,NE,NG,NO,OM,PA,PY,PE,PL,PT,PR,QA,RE,RO,RU,RW,SM,ST,SA,SN,RS,SC,SL,SK,SI,SO,ZA,ES,SD,SR,SJ,SZ,SE,CH,SY,TJ,TZ,TG,TT,TN,TR,TM,TC,UG,UA,AE,GB,US,UY,UZ,VE,EH,YE,ZM,ZW
Zone 3 Shipping Table
100:5.08,200:8.00,300:10.92,400:13.84,500:16.76,600:19.68,700:22.60,800:25.52,900:28.44,1000:31.36,1100:34.28,1200:37.2,1300:40.12,1400:43.04,1500:45.96,1600:48.88,1700:51.80,1800:54.72,1900:57.64,2000:60.56
Zone 3 Handling Fee
0
Handling Per Order or Per Box Zone 3 (when by weight)
Order
Zone 4 Countries
Zone 4 Shipping Table
Zone 4 Handling Fee
0
Handling Per Order or Per Box Zone 4 (when by weight)
Order
Zone 5 Countries
Zone 5 Shipping Table
Zone 5 Handling Fee
0
Handling Per Order or Per Box Zone 5 (when by weight)
Order
Zone 6 Countries
Zone 6 Shipping Table
Zone 6 Handling Fee
0
Handling Per Order or Per Box Zone 6 (when by weight)
Order
Zone 7 Countries
Zone 7 Shipping Table
Zone 7 Handling Fee
0
Handling Per Order or Per Box Zone 7 (when by weight)
Order
Zone 8 Countries
Zone 8 Shipping Table
Zone 8 Handling Fee
0
Handling Per Order or Per Box Zone 8 (when by weight)
Order
Zone 9 Countries
Zone 9 Shipping Table
Zone 9 Handling Fee
0
Handling Per Order or Per Box Zone 9 (when by weight)
Order
Zone 10 Countries
Zone 10 Shipping Table
Zone 10 Handling Fee
0
Handling Per Order or Per Box Zone 10 (when by weight)
Order
Have you gotten this working or are you still having issues?
One of the things that stand out is that your naming conventions for the files, variables and constants are using underscores ...
Your file:
signpost.php
is the closet to correct ...
The other files:
pos_malaysia.php
singpost_plus_posmalaysia.php
should be remade from the file:
signpost.php
where you can change all:
signpost to posmalaysia
SIGNPOST to POSMALAYSIA
and the filenames to posmalaysia.php
and copy then:
signpost to singpostplusposmalaysia
SIGNPOST to SIGNPOSTPLUSPOSMALAYSIA
and the filenames to singpostplusposmalaysia.php
Now add in your customization for the $chk_cat for each one ...
I think the conflicts are worth fixing before you proceed ...
Then remove all traces of the old files from your site for:
pos_malaysia.php
singpost_plus_posmalaysia.php
From here, we can look further into what needs to be done ...
Linda McGrath
If you have to think ... you haven't been zenned ...
Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!
Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here
Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!
Linda McGrath
If you have to think ... you haven't been zenned ...
Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!
Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here
Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!