Quick Search:

View

Revision:

Diff

Diff from 1165 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/branches/frank/osc-tickets/admin/includes/modules/shipping/zones.php

Annotated File View

hpdl
620
1 <?php
2 /*
3   $Id: zones.php 440 2006-02-19 18:40:20Z hpdl $
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
8   Copyright (c) 2006 osCommerce
9
10   Released under the GNU General Public License
11
12   USAGE
13   By default, the module comes with support for 1 zone.  This can be
14   easily changed by editing the line below in the zones constructor
15   that defines $this->num_zones.
16
17   Next, you will want to activate the module by going to the Admin screen,
18   clicking on Modules, then clicking on Shipping.  A list of all shipping
19   modules should appear.  Click on the green dot next to the one labeled
20   zones.php.  A list of settings will appear to the right.  Click on the
21   Edit button.
22
23   PLEASE NOTE THAT YOU WILL LOSE YOUR CURRENT SHIPPING RATES AND OTHER
24   SETTINGS IF YOU TURN OFF THIS SHIPPING METHOD.  Make sure you keep a
25   backup of your shipping settings somewhere at all times.
26
27   If you want an additional handling charge applied to orders that use this
28   method, set the Handling Fee field.
29
30   Next, you will need to define which countries are in each zone.  Determining
31   this might take some time and effort.  You should group a set of countries
32   that has similar shipping charges for the same weight.  For instance, when
33   shipping from the US, the countries of Japan, Australia, New Zealand, and
34   Singapore have similar shipping rates.  As an example, one of my customers
35   is using this set of zones:
36     1: USA
37     2: Canada
38     3: Austria, Belgium, Great Britain, France, Germany, Greenland, Iceland,
39        Ireland, Italy, Norway, Holland/Netherlands, Denmark, Poland, Spain,
40        Sweden, Switzerland, Finland, Portugal, Israel, Greece
41     4: Japan, Australia, New Zealand, Singapore
42     5: Taiwan, China, Hong Kong
43
44   When you enter these country lists, enter them into the Zone X Countries
45   fields, where "X" is the number of the zone.  They should be entered as
46   two character ISO country codes in all capital letters.  They should be
47   separated by commas with no spaces or other punctuation. For example:
48     1: US
49     2: CA
50     3: AT,BE,GB,FR,DE,GL,IS,IE,IT,NO,NL,DK,PL,ES,SE,CH,FI,PT,IL,GR
51     4: JP,AU,NZ,SG
52     5: TW,CN,HK
53
54   Now you need to set up the shipping rate tables for each zone.  Again,
55   some time and effort will go into setting the appropriate rates.  You
56   will define a set of weight ranges and the shipping price for each
57   range.  For instance, you might want an order than weighs more than 0
58   and less than or equal to 3 to cost 5.50 to ship to a certain zone.
59   This would be defined by this:  3:5.5
60
61   You should combine a bunch of these rates together in a comma delimited
62   list and enter them into the "Zone X Shipping Table" fields where "X"
63   is the zone number.  For example, this might be used for Zone 1:
64     1:3.5,2:3.95,3:5.2,4:6.45,5:7.7,6:10.4,7:11.85, 8:13.3,9:14.75,10:16.2,11:17.65,
65     12:19.1,13:20.55,14:22,15:23.45
66
67   The above example includes weights over 0 and up to 15.  Note that
68   units are not specified in this explanation since they should be
69   specific to your locale.
70
71   CAVEATS
72   At this time, it does not deal with weights that are above the highest amount
73   defined.  This will probably be the next area to be improved with the
74   module.  For now, you could have one last very high range with a very
75   high shipping rate to discourage orders of that magnitude.  For
76   instance:  999:1000
77
78   If you want to be able to ship to any country in the world, you will
79   need to enter every country code into the Country fields. For most
80   shops, you will not want to enter every country.  This is often
81   because of too much fraud from certain places. If a country is not
82   listed, then the module will add a $0.00 shipping charge and will
83   indicate that shipping is not available to that destination.
84   PLEASE NOTE THAT THE ORDER CAN STILL BE COMPLETED AND PROCESSED!
85
86   It appears that the osC shipping system automatically rounds the
87   shipping weight up to the nearest whole unit.  This makes it more
88   difficult to design precise shipping tables.  If you want to, you
89   can hack the shipping.php file to get rid of the rounding.
90
91   Lastly, there is a limit of 255 characters on each of the Zone
92   Shipping Tables and Zone Countries.
93
94 */
95
96   class osC_Shipping_zones extends osC_Shipping_Admin {
97     var $num_zones;
98
99     var $_title,
100         $_code = 'zones',
101         $_author_name = 'osCommerce',
102         $_author_www = 'http://www.oscommerce.com',
103         $_status = true,
104         $_sort_order;
105
106 // class constructor
107     function osC_Shipping_zones() {
108       global $osC_Language;
109
110       $this->icon = '';
111
112       $this->_title = $osC_Language->get('shipping_zones_title');
113       $this->_description = $osC_Language->get('shipping_zones_description');
114       $this->_status = (defined('MODULE_SHIPPING_ZONES_STATUS') && (MODULE_SHIPPING_ZONES_STATUS == 'True') ? true : false);
115       $this->_sort_order = (defined('MODULE_SHIPPING_ZONES_SORT_ORDER') ? MODULE_SHIPPING_ZONES_SORT_ORDER : null);
116
117 // CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED
118 // HPDL; also needs to match the value at oscommerce/includes/modules/shipping/zones.php
119       $this->num_zones = 1;
120     }
121
122 // class methods
123     function isInstalled() {
124       return (bool)defined('MODULE_SHIPPING_ZONES_STATUS');
125     }
126
127     function install() {
128       global $osC_Database;
129
130       parent::install();
131
hpdl
758
132       $osC_Database->simpleQuery("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_ZONES_STATUS', 'True', 'Do you want to offer zone rate shipping?', '6', '0', 'osc_cfg_set_boolean_value(array(\'True\', \'False\'))', now())");
133       $osC_Database->simpleQuery("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_ZONES_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'osc_cfg_use_get_tax_class_title', 'osc_cfg_set_tax_classes_pull_down_menu', now())");
hpdl
620
134       $osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_ZONES_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
135
136       for ($i = 1; $i <= $this->num_zones; $i++) {
137         $default_countries = '';
138
139         if ($i == 1) {
140           $default_countries = 'US,CA';
141         }
142
143         $osC_Database->simpleQuery("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_ZONES_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $i . ".', '6', '0', now())");
144         $osC_Database->simpleQuery("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_ZONES_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())");
145         $osC_Database->simpleQuery("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_ZONES_HANDLING_" . $i."', '0', 'Handling Fee for this shipping zone', '6', '0', now())");
hpdl
758
146         $osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Module weight Unit', 'MODULE_SHIPPING_ZONES_WEIGHT_UNIT', '2', 'What unit of weight does this shipping module use?.', '6', '0', 'osC_Weight::getTitle', 'osc_cfg_set_weight_classes_pulldown_menu', now())");
hpdl
620
147       }
148     }
149
150     function getKeys() {
151       if (!isset($this->_keys)) {
152         $this->_keys = array('MODULE_SHIPPING_ZONES_STATUS',
153                              'MODULE_SHIPPING_ZONES_TAX_CLASS',
154                              'MODULE_SHIPPING_ZONES_SORT_ORDER',
155                              'MODULE_SHIPPING_ZONES_WEIGHT_UNIT');
156
157         for ($i=1; $i<=$this->num_zones; $i++) {
158           $this->_keys[] = 'MODULE_SHIPPING_ZONES_COUNTRIES_' . $i;
159           $this->_keys[] = 'MODULE_SHIPPING_ZONES_COST_' . $i;
160           $this->_keys[] = 'MODULE_SHIPPING_ZONES_HANDLING_' . $i;
161         }
162       }
163
164       return $this->_keys;
165     }
166   }
167 ?>