Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Local vs International Table Rate


Guest

Recommended Posts

Posted

Hi,

I would like to have two shipments rates, local and international. And both of them require 2 diff categoies.

 

Local rate has its 5 zones and 2 categories (<500gms and additional 250gm).

International rate, not yet has zone but has categ (1st 500gm and Next 500gm).

Differenct country has different shipment rate, and I need to separate them into groups. I noticed that I am only allowed to have max 5 zones.

How can I acheived these local and int table rates?

 

I tried to create anothe file (local.php) copied from table.php as suggested in the documentaion, but failed.

Appreciate the assist...

Posted
i have accomplished seperate rates for local and international shipping, thanks to the help of enigma1 :)

 

here's the topic:

http://www.oscommerce.com/forums/index.php?sho...13entry703513

 

Which file do I need to copy from for local zone shipping rate, table.php or zone.php?

Local Malaysia rate has 5 zones and each zone has its 2 rates, first 500grams and additiona 250grams.

Posted

to be quite honest, i'm not sure. enigma made some changes to the file for me, so i don't know. i will post all of my files for you, use all of them. just rename them accordingly to your needs:

 

includes/modules/shipping/usair.php

<?php
/*
$Id: usair.php,v 1.27 2003/02/05 22:41:52 hpdl Exp $

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright (c) 2003 osCommerce

Released under the GNU General Public License
*/

class usair {
  var $code, $title, $description, $icon, $enabled;

// class constructor
  function usair() {
 global $order;

 $this->code = 'usair';
 $this->title = MODULE_SHIPPING_USAIR_TEXT_TITLE;
 $this->description = MODULE_SHIPPING_USAIR_TEXT_DESCRIPTION;
 $this->sort_order = MODULE_SHIPPING_USAIR_SORT_ORDER;
 $this->icon = '';
 $this->tax_class = MODULE_SHIPPING_USAIR_TAX_CLASS;
 $this->enabled = ((MODULE_SHIPPING_USAIR_STATUS == 'True') ? true : false);

 $check_flag == $this->enabled;
 $check_query = tep_db_query("select zone_id, zone_country_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$order->delivery['country']['id'] . "' order by zone_id");
 if($check = tep_db_fetch_array($check_query)) {
   if( $check['zone_country_id'] == 223 || $check['zone_country_id'] == 38 ) {
	 $check_flag = true;
   } else {
	 $check_flag = false;
   }
 } else {
   $check_flag = false;
 }
 $this->enabled = $check_flag;

 if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_USAIR_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_USAIR_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, $cart, $shipping_weight, $shipping_num_boxes;

 if (MODULE_SHIPPING_USAIR_MODE == 'price') {
   $order_total = $cart->show_total();
 } else {
   $order_total = $shipping_weight;
 }

 $usair_cost = split("[:,]" , MODULE_SHIPPING_USAIR_COST);
 $size = sizeof($usair_cost);
 for ($i=0, $n=$size; $i<$n; $i+=2) {
   if ($order_total <= $usair_cost[$i]) {
	 $shipping = $usair_cost[$i+1];
	 break;
   }
 }

 if (MODULE_SHIPPING_USAIR_MODE == 'weight') {
   $shipping = $shipping * $shipping_num_boxes;
 }

 $this->quotes = array('id' => $this->code,
					   'module' => MODULE_SHIPPING_USAIR_TEXT_TITLE,
					   'methods' => array(array('id' => $this->code,
												'title' => MODULE_SHIPPING_USAIR_TEXT_WAY,
												'cost' => $shipping + MODULE_SHIPPING_USAIR_HANDLING)));

 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_USAIR_STATUS'");
   $this->_check = tep_db_num_rows($check_query);
 }
 return $this->_check;
  }

  function install() {
 tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Table Method', 'MODULE_SHIPPING_USAIR_STATUS', 'True', 'Do you want to offer usair rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
 tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Table', 'MODULE_SHIPPING_USAIR_COST', '25:8.50,50:5.50,10000:0.00', 'The shipping 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', '6', '0', now())");
 tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Table Method', 'MODULE_SHIPPING_USAIR_MODE', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered.', '6', '0', 'tep_cfg_select_option(array(\'weight\', \'price\'), ', now())");
 tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_USAIR_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', 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_USAIR_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', '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_USAIR_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', '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_USAIR_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
  }

  function remove() {
 tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
  }

  function keys() {
 return array('MODULE_SHIPPING_USAIR_STATUS', 'MODULE_SHIPPING_USAIR_COST', 'MODULE_SHIPPING_USAIR_MODE', 'MODULE_SHIPPING_USAIR_HANDLING', 'MODULE_SHIPPING_USAIR_TAX_CLASS', 'MODULE_SHIPPING_USAIR_ZONE', 'MODULE_SHIPPING_USAIR_SORT_ORDER');
  }
}
?>

 

includes/modules/shipping/table3.php (i use this one for international rates)

<?php
/*
$Id: table3.php,v 1.27 2003/02/05 22:41:52 hpdl Exp $

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright ? 2003 osCommerce

Released under the GNU General Public License
*/

class table3 {
var $code, $title, $description, $icon, $enabled;

// class constructor
function table3() {
global $order;

$this->code = 'table3';
$this->title = MODULE_SHIPPING_TABLE3_TEXT_TITLE;
$this->description = MODULE_SHIPPING_TABLE3_TEXT_DESCRIPTION;
$this->sort_order = MODULE_SHIPPING_TABLE3_SORT_ORDER;
$this->icon = '';
$this->tax_class = MODULE_SHIPPING_TABLE3_TAX_CLASS;
$this->enabled = ((MODULE_SHIPPING_TABLE3_STATUS == 'True') ? true : false);

$check_flag == $this->enabled;
$check_query = tep_db_query("select zone_id, zone_country_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$order->delivery['country']['id'] . "' order by zone_id");
if($check = tep_db_fetch_array($check_query)) {
if( $check['zone_country_id'] == 223 || $check['zone_country_id'] == 38 ) {
$check_flag = false;
} else {
$check_flag = true;
}
} else {
$check_flag = true;
}

$this->enabled = $check_flag;


if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLE3_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_TABLE3_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, $cart, $shipping_weight, $shipping_num_boxes;

if (MODULE_SHIPPING_TABLE3_MODE == 'price') {
$order_total = $cart->show_total();
} else {
$order_total = $shipping_weight;
}

$table_cost = split("[:,]" , MODULE_SHIPPING_TABLE3_COST);
$size = sizeof($table_cost);
for ($i=0, $n=$size; $i<$n; $i+=2) {
if ($order_total <= $table_cost[$i]) {
$shipping = $table_cost[$i+1];
break;
}
}

if (MODULE_SHIPPING_TABLE3_MODE == 'weight') {
$shipping = $shipping * $shipping_num_boxes;
}

$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_TABLE3_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_TABLE3_TEXT_WAY,
'cost' => $shipping + MODULE_SHIPPING_TABLE3_HANDLING)));

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_TABLE3_STATUS'");
$this->_check = tep_db_num_rows($check_query);
}
return $this->_check;
}

function install() {
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Table Method', 'MODULE_SHIPPING_TABLE3_STATUS', 'True', 'Do you want to offer table rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Table', 'MODULE_SHIPPING_TABLE3_COST', '25:8.50,50:5.50,10000:0.00', 'The shipping 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', '6', '0', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Table Method', 'MODULE_SHIPPING_TABLE3_MODE', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered.', '6', '0', 'tep_cfg_select_option(array(\'weight\', \'price\'), ', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_TABLE3_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', 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_TABLE3_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', '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_TABLE3_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', '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_TABLE3_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
}

function remove() {
tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}

function keys() {
return array('MODULE_SHIPPING_TABLE3_STATUS', 'MODULE_SHIPPING_TABLE3_COST', 'MODULE_SHIPPING_TABLE3_MODE', 'MODULE_SHIPPING_TABLE3_HANDLING', 'MODULE_SHIPPING_TABLE3_TAX_CLASS', 'MODULE_SHIPPING_TABLE3_ZONE', 'MODULE_SHIPPING_TABLE3_SORT_ORDER');
}
}
?>

 

includes/languages/english/modules/shipping/usair.php

<?php
/*
 $Id: usair.php,v 1.5 2002/11/19 01:48:08 dgw_ Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
*/

define('MODULE_SHIPPING_USAIR_TEXT_TITLE', 'Air Mail');
define('MODULE_SHIPPING_USAIR_TEXT_DESCRIPTION', 'US Airmail');
define('MODULE_SHIPPING_USAIR_TEXT_WAY', 'Delivery estimate approx 7 to 10  business days after dispatch');
define('MODULE_SHIPPING_USAIR_TEXT_WEIGHT', 'Weight');
define('MODULE_SHIPPING_USAIR_TEXT_AMOUNT', 'Amount');
?>

 

includes/languages/english/modules/shipping/table3.php (i use this for international rates)

<?php
/*
 $Id: table.php,v 1.5 2002/11/19 01:48:08 dgw_ Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
*/

define('MODULE_SHIPPING_TABLE3_TEXT_TITLE', 'Airmail');
define('MODULE_SHIPPING_TABLE3_TEXT_DESCRIPTION', 'Overseas Airmail');
define('MODULE_SHIPPING_TABLE3_TEXT_WAY', 'Delivery estimate approx 1 to 2 weeks after dispatch');
define('MODULE_SHIPPING_TABLE3_TEXT_WEIGHT', 'Weight');
define('MODULE_SHIPPING_TABLE3_TEXT_AMOUNT', 'Amount');
?>

 

 

 

this part is optional, but this is what i did to offer ground mail too.

 

- duplicate source code for includes/modules/shipping/usair.php and rename file to usground.php

- find/replace all instances of USAIR (to be safe, FIRST do a find/replace match case for usair and change to usground), then do a find/replace match case for USAIR and change to USGROUND

- duplicate includes/languages/english/modules/shipping/usair.php and repeat the above steps.. then edit the terms inside the language file accordingly.

 

it took me a few trial & error's to get the second rate option available for both locations

Posted
to be quite honest, i'm not sure. enigma made some changes to the file for me, so i don't know. i will post all of my files for you, use all of them. just rename them accordingly to your needs:

 

this part is optional, but this is what i did to offer ground mail too.

 

- duplicate source code for includes/modules/shipping/usair.php and rename file to usground.php

- find/replace all instances of USAIR (to be safe, FIRST do a find/replace match case for usair and change to usground), then do a find/replace match case for USAIR and change to USGROUND

- duplicate includes/languages/english/modules/shipping/usair.php and repeat the above steps.. then edit the terms inside the language file accordingly.

 

it took me a few trial & error's to get the second rate option available for both locations

 

Thanks. I will look at them...

Posted
Thanks. I will look at them...

 

Based on your files here, you have two shipping types [local and oversea]. And each shipping type, has only one zone. These are good if you have one zone only.

 

My scenario is over local (Malaysia) shipping type has 5 zones, and oversea type has over 62 countries that have not been grouped yet. of course, I need to group them first.

 

BTW, I used your usair.php for my local shipping, even though my local has 5 zones.

 

I tried to use use zone.php to modify for overseas, but this script has limitation to 5 zones only.

Maybe I will try this file for my local one.

Posted
Based on your files here, you have two shipping types [local and oversea]. And each shipping type, has only one zone. These are good if you have one zone only.

 

My scenario is over local (Malaysia) shipping type has 5 zones, and oversea type has over 62 countries that have not been grouped yet. of course, I need to group them first.

 

BTW, I used your usair.php for my local shipping, even though my local has 5 zones.

 

I tried to use use zone.php to modify for overseas, but this script has limitation to 5 zones only.

Maybe I will try this file for my local one.

 

hello

are you sure zones can only have 5 zones? I seem to remember setting a test site up and used 15 zones in the zones shipping table.

 

F5

Posted
Based on your files here, you have two shipping types [local and oversea]. And each shipping type, has only one zone. These are good if you have one zone only.

 

My scenario is over local (Malaysia) shipping type has 5 zones, and oversea type has over 62 countries that have not been grouped yet. of course, I need to group them first.

 

BTW, I used your usair.php for my local shipping, even though my local has 5 zones.

 

I tried to use use zone.php to modify for overseas, but this script has limitation to 5 zones only.

Maybe I will try this file for my local one.

 

not sure what you mean? i didn't have to add/modify or group any zones or countries. these are "table rates".

i've tested using several different overseas, us, canada addresses - they all calculated properly just by adding these files :thumbsup:

Posted
hello

are you sure zones can only have 5 zones? I seem to remember setting a test site up and used 15 zones in the zones shipping table.

 

F5

 

My mistake. I copied the other zone.php file. I got it 11 zones created now.

TQ

Posted
not sure what you mean? i didn't have to add/modify or group any zones or countries. these are "table rates".

i've tested using several different overseas, us, canada addresses - they all calculated properly just by adding these files :thumbsup:

 

Correct, I think the oversea table rate is fine. The only thing I trouble me is that I change the country of a test client to the USA address, the shipping rate is not the same as manual calculation. Maybe the setting is off somewhere.

 

The local one I think is puzzling me since local shipping has like this:

Zone 1: Local Town Delivery

Zone 2: Within Peninsular Malaysia

ZOne 3: Between Sabah & Sarawak

Zone 4: Betweek Peninsular and Sarawak

Zone 5: Between Peninsular and Sabah.

 

Zone 1 should be the same local delivery from the our place.

Zone 2: the rest of state in Peninsular (10 or 11 states)

Zone 3: Sabah & Sarawak (another 2 states in located in Borneo Island)

 

The table is like this:

First 500gm: Z1 9.50; Z2 16.00; Z3 21.00; Z4 26.00; Z5 31.00

Add 250gm: Z1 0.50; Z2 2.00; Z3 3.00; Z4 3.50; Z5 4.00

 

Your local table rate is for one zone in country; US one zone and CA one zone.

Posted

i'm pretty sure the weight option rounds up, so could that be where the calculation is going wrong?

Posted
i'm pretty sure the weight option rounds up, so could that be where the calculation is going wrong?

 

Now i got "No shipping available" for US address using the original zone.php with default coutries = MY and contry = Malaysia in mystore setting.

 

What is the problem?

Posted

try to use only table rates and see if it works (multiply the code as many times as you need it), i haven't tried these contributions with other shipping modules - they may be cancelling eachother out.

 

were you able to change the u.s./canada module to fit your country specifications?

Posted
try to use only table rates and see if it works (multiply the code as many times as you need it), i haven't tried these contributions with other shipping modules - they may be cancelling eachother out.

 

were you able to change the u.s./canada module to fit your country specifications?

When I enable the table rate that you provided, it works (for shiiping to US address). See below:

 

Please select the preferred shipping method to use on this order. Please Select

 

Oversea Zone Rates

No shipping available to the selected country

 

Oversea Pos Laju

Delivery estimate approx 1 to 2 weeks after dispatch RM55.00

 

Zone Rates

No shipping available to the selected country

Posted

that's weird, so by the looks of it it's cancelling them out (my files)?

enigma1 seems to be the master with the shipping modules, if enigma1 doesn't come across this topic i would suggest to pm and see if there's any suggestions

 

or do what i do: keep bumping your topic periodically until the right person comes across it :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...