Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Zones.php question


Avium

Recommended Posts

Hi guys,

 

I'm planning to use multiple duplicates of the zones.php shipping file because I'm using the zones system, but will be offering various options like surface mail, registered air mail, EMS and the likes.

 

Aside from creating new zones.php files (renamed differently of course) and putting them under the modules/shipping folder for both the catalog and the catalog language folder, what else must I do?

Link to comment
Share on other sites

I hate to add a "me too" post - but since I'm having problems with the USPS International module I need to create some zones ASAP to fix the problem.

 

We only ship to Japan, but I need to set up the option of Airmail, Economy Mail, EMS, and Parcel Post.

 

Thanks for any replies.

 

Paul

Link to comment
Share on other sites

Well I posted this a couple of topics below - the USPS international module is currently not functioning properly on my install. It comes back with "ERROR" whenever you try to check out. It's worked fine for the past year and a half and suddenly started screwing up - I haven't touched the code on my site since we launched, so I'm guessing the USPS is doing something different.

 

Paul

Link to comment
Share on other sites

Hi,

 

yes, you can have multiple zone files, but you will need to rename the constants throughout.

 

For instance, wherever you find things like:

 

MODULE_SHIPPING_ZONES_TEXT_TITLE

MODULE_SHIPPING_ZONES_TEXT_DESCRIPTION

MODULE_SHIPPING_ZONES_SORT_ORDER

MODULE_SHIPPING_ZONES_TAX_CLASS

 

etc, you would need to give them new names such as:

 

MODULE_SHIPPING_ZONES2_TEXT_TITLE

MODULE_SHIPPING_ZONES2_TEXT_DESCRIPTION

MODULE_SHIPPING_ZONES2_SORT_ORDER

MODULE_SHIPPING_ZONES2_TAX_CLASS

 

This is so that separate entries are held in the database for the 2 different zone arrangements.

 

Note, you have to make these changes in both the file in /catalog/includes/modules/shipping/ and the one in /catalog/includes/languages/english/modules/shipping

 

HTH,

Link to comment
Share on other sites

Paulrus,

Have you contacted the USPS. They have made some changes and they will be happy to help.. They are familiar with OSCommerce. What OSC version are you running? The USPS Methods for MS! & MS2 version runs great. One question, have you recently added any new contributions?

I have USPSMethods running on a test sight and when I load MasterProducts I lost functions from the general.php in both catalog and admin and the same for both modules.php. Now, I log each file that has been changed when contributions are added. Then when I want to load a new contribution for testing I run a text comparison program on any files that are going to change in the new contribution against the same existing file I already have running. It sure eliminates a lot of problems later. My USPSMethods I added several lines of code to include, in the costs presented to the customer, preset standards for insurance, registered, delivery confirmation, delivery receipt, signature confirmation. Right now the $$$ levels are hard coded but I am working on making it configurable from admin, i.e. turn services on or off, set $$ amounts at which to apply. I had to fly by the seat of my pants on this one, other than insurance there just aren't any other contributions that fit.

If I can be of help please let me know.

Link to comment
Share on other sites

Thanks. I haven't actually touched any of the code in well over a year. I'm running OSC 2.2 CVS June 2002 release. Because we did a lot of customization for the Japanese market we've never been able to update it beyond what we're running.

 

I went with zones for now - basically there is only 1 zone and that is Japan. I'll probably add multiple zones, but I don't know if I'll add multiple versions to compensate for various shipping options. I'll probably just leave it with airmail for under 4 pounds and parcel post for everything over that.

 

Thanks

 

Paul

Link to comment
Share on other sites

  • 2 weeks later...

HYE GUYS

I try do do exactaly as you said .Duplicate zone.php , rename zone2.php ,change in adim/modeles/language and in calatog/includes/modules/shipping/ I change all reference in zone2.php to zone2 whereeer it was but .em I log in modules this show up

 

Warning: main(/home/hammocks/public_html/catalog/includes/languages/english/modules/shipping/zone2.php): failed to open stream: No such file or directory in /home/hammocks/public_html/catalog/admin/modules.php on line 128

 

Warning: main(): Failed opening '/home/hammocks/public_html/catalog/includes/languages/english/modules/shipping/zone2.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/hammocks/public_html/catalog/admin/modules.php on line 128

 

Fatal error: Cannot redeclare class zones in /home/hammocks/public_html/catalog/includes/modules/shipping/zones.php on line 97

 

 

 

what I missed ?

thansk for any help

cass

Link to comment
Share on other sites

Hi Cass,

 

it sounds like mainly you missed the language files and also something else, which I will cover in due course.

 

First of all, make copies of the /catalog/includes/languages/english/modules/shipping/zones.php and call it zones2.php (in the same folder obviously). Then change add the 2's as required inside the file, like before.

 

The last error message you quote there is something different. I think you need to revisit your /catalog/modules/shipping/zones.php file. You should have changed the name of the class itself from zones to zones2 but I suspect this is not the case.

 

HTH,

Link to comment
Share on other sites

class zones {

var $code, $title, $description, $enabled, $num_zones;

 

// class constructor

function zones() {

$this->code = 'zones';

$this->title = MODULE_SHIPPING_ZONES2_TEXT_TITLE;

$this->description = MODULE_SHIPPING_ZONES2_TEXT_DESCRIPTION;

$this->sort_order = MODULE_SHIPPING_ZONES2_SORT_ORDER;

$this->icon = '';

$this->tax_class = MODULE_SHIPPING_ZONES2_TAX_CLASS;

$this->enabled = ((MODULE_SHIPPING_ZONES2_STATUS == 'True') ? true : false);

 

// CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED

$this->num_zones = 1;

}

 

// class methods

function quote($method = '') {

global $order, $shipping_weight, $shipping_num_boxes;

 

$dest_country = $order->delivery['country']['iso_code_2'];

$dest_zone = 0;

$error = false;

 

for ($i=1; $i<=$this->num_zones; $i++) {

$countries_table = constant('MODULE_SHIPPING_ZONES2_COUNTRIES_' . $i);

$country_zones = split("[,]", $countries_table);

if (in_array($dest_country, $country_zones)) {

$dest_zone = $i;

break;

}

}

 

if ($dest_zone == 0) {

$error = true;

} else {

$shipping = -1;

$zones_cost = constant('MODULE_SHIPPING_ZONES2_COST_' . $dest_zone);

 

$zones_table = split("[:,]" , $zones_cost);

$size = sizeof($zones_table);

for ($i=0; $i<$size; $i+=2) {

if ($shipping_weight <= $zones_table[$i]) {

$shipping = $zones_table[$i+1];

$shipping_method = MODULE_SHIPPING_ZONES2_TEXT_WAY . ' ' . $dest_country . ' : ' . $shipping_weight . ' ' . MODULE_SHIPPING_ZONES2_TEXT_UNITS;

break;

}

}

 

if ($shipping == -1) {

$shipping_cost = 0;

$shipping_method = MODULE_SHIPPING_ZONES2_UNDEFINED_RATE;

} else {

$shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_ZONES2_HANDLING_' . $dest_zone);

}

}

 

$this->quotes = array('id' => $this->code,

'module' => MODULE_SHIPPING_ZONES2_TEXT_TITLE,

'methods' => array(array('id' => $this->code,

'title' => $shipping_method,

'cost' => $shipping_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);

 

if ($error == true) $this->quotes['error'] = MODULE_SHIPPING_ZONES2_INVALID_ZONE;

 

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_ZONES2_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 Zones Method', 'MODULE_SHIPPING_ZONES2_STATUS', 'True', 'Do you want to offer zone 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, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_ZONES2_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, date_added) values ('Sort Order', 'MODULE_SHIPPING_ZONES2_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");

for ($i = 1; $i <= $this->num_zones; $i++) {

$default_countries = '';

if ($i == 1) {

$default_countries = 'US,CA';

}

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone " . $i ." Countries', 'MODULE_SHIPPING_ZONES2_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $i . ".', '6', '0', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone " . $i ." Shipping Table', 'MODULE_SHIPPING_ZONES2_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. Example: 3:8.50,7:10.50,... Weights less than or equal to 3 would cost 8.50 for Zone " . $i . " destinations.', '6', '0', now())");

tep_db_query("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_ZONES2_HANDLING_" . $i."', '0', 'Handling Fee for this shipping zone', '6', '0', now())");

}

}

 

function remove() {

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

}

 

function keys() {

$keys = array('MODULE_SHIPPING_ZONES2_STATUS', 'MODULE_SHIPPING_ZONES2_TAX_CLASS', 'MODULE_SHIPPING_ZONES2_SORT_ORDER');

 

for ($i=1; $i<=$this->num_zones; $i++) {

$keys[] = 'MODULE_SHIPPING_ZONES2_COUNTRIES_' . $i;

$keys[] = 'MODULE_SHIPPING_ZONES2_COST_' . $i;

$keys[] = 'MODULE_SHIPPING_ZONES2_HANDLING_' . $i;

}

 

return $keys;

}

}

?>

Thanks mark there goes my zone2.php

Link to comment
Share on other sites

and I also change in language/

 

<?php

/*

$Id: zones.php,v 1.3 2002/11/19 01:48:08 dgw_ Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2002 osCommerce

 

Released under the GNU General Public License

*/

 

define('MODULE_SHIPPING_ZONES2_TEXT_TITLE', 'EMS MAIL 3-5 DAYS');

define('MODULE_SHIPPING_ZONES2_TEXT_DESCRIPTION', 'Zone Based Rates');

define('MODULE_SHIPPING_ZONES2_TEXT_WAY', 'Shipping to');

define('MODULE_SHIPPING_ZONES2_TEXT_UNITS', 'lb(s)');

define('MODULE_SHIPPING_ZONES2_INVALID_ZONE', 'No shipping available to the selected country');

define('MODULE_SHIPPING_ZONES2_UNDEFINED_RATE', 'The shipping rate cannot be determined at this time');

?>

Link to comment
Share on other sites

I was wondering if ,prior upload those new files you suppose to have zone rate uninstalled .

Because I doing with a zone rate installed already .

 

Might be this?

 

thanks mark

Link to comment
Share on other sites

Hye guys ,we almost there ..

 

What I did ...was

 

Delete from the server and see that it back to the normal

Well ..I check all changes and all was perfect .

So I start to try new things

 

I did unistall the zone rate module . I upload the files and it doesn't show the first erro . Only the class error show up .

Well , i find the erro ... I rename files zone2.php NOT ZONES2.PHP ... dummyy

 

I get back to zones2.php and change the class to zones2 too to see if I can fix the second erro .

It work......I was quit happy when show one new file

 

I can add name in the language/english/ I did but it wont change ..I change in the zones.php and it work . So I find some is wrong

 

Final teste ( install ) first zone rates installed ....Second zone rate ( with no name blank ) it wont install ,It goes back to same install file

 

 

Now the question is ... What happen now ? It suppose to rename and install ...where is my mistake ?????/ thanks ...

Link to comment
Share on other sites

Guys ,,,I put some sublime music and start to figure what might be wrong

 

Well class ????/ lets try :

 

 

 

// class constructor

function zones2() {

$this->code = 'zones2';

$this->title = MODULE_SHIPPING_ZONES2_TEXT_TITLE;

$this->description = MODULE_SHIPPING_ZONES2_TEXT_DESCRIPTION;

$this->sort_order = MODULE_SHIPPING_ZONES2_SORT_ORDER;

$this->icon = '';

$this->tax_class = MODULE_SHIPPING_ZONES2_TAX_CLASS;

$this->enabled = ((MODULE_SHIPPING_ZONES2_STATUS == 'false') ? true : false);

Link to comment
Share on other sites

Dont forget to add 2 to the class on top too

 

 

class zones2 {

var $code, $title, $description, $enabled, $num_zones;

 

// class constructor

function zones2() {

$this->code = 'zones2';

$this->title = MODULE_SHIPPING_ZONES2_TEXT_TITLE;

$this->description = MODULE_SHIPPING_ZONES2_TEXT_DESCRIPTION;

$this->sort_order = MODULE_SHIPPING_ZONES2_SORT_ORDER;

$this->icon = '';

$this->tax_class = MODULE_SHIPPING_ZONES2_TAX_CLASS;

$this->enabled = ((MODULE_SHIPPING_ZONES2_STATUS == 'false') ? true : false);

Link to comment
Share on other sites

Guys

Everything looks perfect

I have shipping module without error message ,and two zones modules installed

Regular shipping

EMS shipping

 

Perfect until I procide to check out . I set my adress to US .

I set both shipping modules to US .

 

Problem :

 

Upon check out ,only ONE ( the zones.php ) shows up ...

The Second ( zones2.php ) is not been add to be a choice upon check out

 

What I missing >?? SHould I change anything in check_out_shipping.php ?

 

thanks for any tip

cass

 

PS : I will post the whole process after conclude ,to help others

Link to comment
Share on other sites

  • 2 weeks later...

I have a similar Problem and maybee someone can help:

 

I dublicated the zones.php and renamed to zones_ups.php. I defined the countries and shipping cocts and it also shows on the certain plaace where the customer can choose the shipping.

 

BUT

When he comes to the last page of the ordering process and he had chosen the dublicated zones module the shipping module is set back to the original zones.php module and its costs.

 

Can somepn explain ths= I renamed all zones into zones_ups in the zones_ups file, also the class and code and texts and so on. Also created the language files. AND I HAVE NO ERRORS; BUT IT DOESN'T WORK

 

Please help me

Link to comment
Share on other sites

  • 4 weeks later...

Archived

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

×
×
  • Create New...