Page 1 of 2 12 LastLast
Results 1 to 10 of 18
  1. #1
    Join Date
    Aug 2006
    Location
    UK
    Posts
    119
    Plugin Contributions
    0

    Default Can I duplicate the zones module?

    Hi all.

    The book seller here again.. lol.

    I have set up the zones module which enables me to price for UK 1st Class, Europe Airmail, and Rest of World Airmail.
    All works great.

    But can I duplicate the module for further settings, IE (UK 2nd Class, Surfacemail, Recorded Delivery etc)?

    Or, if not can I add extra zones to the existing module, and would they show up in Admin?

    Thanks for any advice in advance.


    Regards Chris
    Zen Lover.


  2. #2
    Join Date
    Nov 2006
    Posts
    206
    Plugin Contributions
    0

    Default Re: Can I duplicate the zones module?

    I would like to know the answer to this too!

  3. #3
    Join Date
    Aug 2004
    Location
    Belfast, Northern Ireland
    Posts
    2,480
    Plugin Contributions
    14

    Default Re: Can I duplicate the zones module?

    Hi,

    We recently created a new shipping module based on Country and optional Postcodes/Postcode Ranges (more expensive deliveries for Highlands/Islands or Corsica as opposed to the rest of France etc.).

    Our client then wanted the same Country/Postcode combinations but as an additional "Next Day Express" delivery option.

    There was no other way to do this other than to create an identical module with a different class name and define names (literally by adding the number 2 on to the end!).

    Just copy the files of whatever module you want to duplicate, rename the class (and its shipping code of course) to xxx2 then all the MODULE_SHIPPING_xxx defines to MODULE_SHIPPING_xxx_2.

    It's not very elegant but unfortunately Zen Cart isn't yet smart enough to allow the usage of the same shipping module with multiple configurations. I'd imagine it will be in the future though...

    All the best...

    Conor
    ceon

  4. #4

    Default Re: Can I duplicate the zones module?

    Hello.

    How it worked corectly?

    I make clone of zones.php in locationas: includes/modules/shipping and includes/landuages/english/modules/shipping

    to zones1.php in both places.

    In small zones.php file
    PHP Code:
    <?php
    //
    // +----------------------------------------------------------------------+
    // |zen-cart Open Source E-commerce                                       |
    // +----------------------------------------------------------------------+
    // | Copyright (c) 2003 The zen-cart developers                           |
    // |                                                                      |   
    // | [url]http://www.zen-cart.com/index.php[/url]                                    |   
    // |                                                                      |   
    // | Portions Copyright (c) 2003 osCommerce                               |
    // +----------------------------------------------------------------------+
    // | This source file is subject to version 2.0 of the GPL license,       |
    // | that is bundled with this package in the file LICENSE, and is        |
    // | available through the world-wide-web at the following url:           |
    // | [url]http://www.zen-cart.com/license/2_0.txt[/url].                             |
    // | If you did not receive a copy of the zen-cart license and are unable |
    // | to obtain it through the world-wide-web, please send a note to       |
    // | [email protected] so we can mail you a copy immediately.          |
    // +----------------------------------------------------------------------+
    // $Id: zones.php 1969 2005-09-13 06:57:21Z drbyte $
    //

    define('MODULE_SHIPPING_ZONES_TEXT_TITLE''smal pockets |up to 2kg - no tracing|');
    define('MODULE_SHIPPING_ZONES_TEXT_DESCRIPTION''Zone Based Rates');
    define('MODULE_SHIPPING_ZONES_TEXT_WAY''Shipping to');
    define('MODULE_SHIPPING_ZONES_TEXT_UNITS''kg');
    define('MODULE_SHIPPING_ZONES_INVALID_ZONE''No shipping available to the selected country');
    define('MODULE_SHIPPING_ZONES_UNDEFINED_RATE''The shipping rate cannot be determined at this time');
    ?>

    I changed defines and make next zones1.php

    PHP Code:
    <?php
    //
    // +----------------------------------------------------------------------+
    // |zen-cart Open Source E-commerce                                       |
    // +----------------------------------------------------------------------+
    // | Copyright (c) 2003 The zen-cart developers                           |
    // |                                                                      |   
    // | http://www.zen-cart.com/index.php                                    |   
    // |                                                                      |   
    // | Portions Copyright (c) 2003 osCommerce                               |
    // +----------------------------------------------------------------------+
    // | This source file is subject to version 2.0 of the GPL license,       |
    // | that is bundled with this package in the file LICENSE, and is        |
    // | available through the world-wide-web at the following url:           |
    // | http://www.zen-cart.com/license/2_0.txt.                             |
    // | If you did not receive a copy of the zen-cart license and are unable |
    // | to obtain it through the world-wide-web, please send a note to       |
    // | [email protected] so we can mail you a copy immediately.          |
    // +----------------------------------------------------------------------+
    // $Id: zones.php 1969 2005-09-13 06:57:21Z drbyte $
    //

    define('MODULE_SHIPPING_ZONES_TEXT_TITLE_1''Parcel Post |up to 31kg - with tracing|');
    define('MODULE_SHIPPING_ZONES_TEXT_DESCRIPTION_1''Zone Based Rates');
    define('MODULE_SHIPPING_ZONES_TEXT_WAY_1''Shipping to');
    define('MODULE_SHIPPING_ZONES_TEXT_UNITS_1''kg');
    define('MODULE_SHIPPING_ZONES_INVALID_ZONE_1''No shipping available to the selected country');
    define('MODULE_SHIPPING_ZONES_UNDEFINED_RATE_1''The shipping rate cannot be determined at this time');
    ?>


    in big zones.php:

    PHP Code:
    <?php
    /**
     * @package shippingMethod
     * @copyright Copyright 2003-2006 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: zones.php 4805 2006-10-22 02:32:33Z ajeh $
     */
    /*

      USAGE
      By default, the module comes with support for 3 zones.  This can be
      easily changed by editing the line below in the zones constructor
      that defines $this->num_zones.

      Next, you will want to activate the module by going to the Admin screen,
      clicking on Modules, then clicking on Shipping.  A list of all shipping
      modules should appear.  Click on the green dot next to the one labeled
      zones.php.  A list of settings will appear to the right.  Click on the
      Edit button.

      PLEASE NOTE THAT YOU WILL LOSE YOUR CURRENT SHIPPING RATES AND OTHER
      SETTINGS IF YOU TURN OFF THIS SHIPPING METHOD.  Make sure you keep a
      backup of your shipping settings somewhere at all times.

      If you want an additional handling charge applied to orders that use this
      method, set the Handling Fee field.

      Next, you will need to define which countries are in each zone.  Determining
      this might take some time and effort.  You should group a set of countries
      that has similar shipping charges for the same weight.  For instance, when
      shipping from the US, the countries of Japan, Australia, New Zealand, and
      Singapore have similar shipping rates.  As an example, one of my customers
      is using this set of zones:
        1: USA
        2: Canada
        3: Austria, Belgium, Great Britain, France, Germany, Greenland, Iceland,
           Ireland, Italy, Norway, Holland/Netherlands, Denmark, Poland, Spain,
           Sweden, Switzerland, Finland, Portugal, Israel, Greece
        4: Japan, Australia, New Zealand, Singapore
        5: Taiwan, China, Hong Kong

      When you enter these country lists, enter them into the Zone X Countries
      fields, where "X" is the number of the zone.  They should be entered as
      two character ISO country codes in all capital letters.  They should be
      separated by commas with no spaces or other punctuation. For example:
        1: US
        2: CA
        3: AT,BE,GB,FR,DE,GL,IS,IE,IT,NO,NL,DK,PL,ES,SE,CH,FI,PT,IL,GR
        4: JP,AU,NZ,SG
        5: TW,CN,HK

      Now you need to set up the shipping rate tables for each zone.  Again,
      some time and effort will go into setting the appropriate rates.  You
      will define a set of weight ranges and the shipping price for each
      range.  For instance, you might want an order than weighs more than 0
      and less than or equal to 3 to cost 5.50 to ship to a certain zone.
      This would be defined by this:  3:5.5

      You should combine a bunch of these rates together in a comma delimited
      list and enter them into the "Zone X Shipping Table" fields where "X"
      is the zone number.  For example, this might be used for Zone 1:
        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,
        12:19.1,13:20.55,14:22,15:23.45

      The above example includes weights over 0 and up to 15.  Note that
      units are not specified in this explanation since they should be
      specific to your locale.

      CAVEATS
      At this time, it does not deal with weights that are above the highest amount
      defined.  This will probably be the next area to be improved with the
      module.  For now, you could have one last very high range with a very
      high shipping rate to discourage orders of that magnitude.  For
      instance:  999:1000

      If you want to be able to ship to any country in the world, you will
      need to enter every country code into the Country fields. For most
      shops, you will not want to enter every country.  This is often
      because of too much fraud from certain places. If a country is not
      listed, then the module will add a $0.00 shipping charge and will
      indicate that shipping is not available to that destination.
      PLEASE NOTE THAT THE ORDER CAN STILL BE COMPLETED AND PROCESSED!

      It appears that the osC shipping system automatically rounds the
      shipping weight up to the nearest whole unit.  This makes it more
      difficult to design precise shipping tables.  If you want to, you
      can hack the shipping.php file to get rid of the rounding.

      Lastly, there is a limit of 255 characters on each of the Zone
      Shipping Tables and Zone Countries.

    */

      
    class zones {
        var 
    $code$title$description$enabled$num_zones;

    // class constructor
        
    function zones() {
          
    $this->code 'zones';
          
    $this->title MODULE_SHIPPING_ZONES_TEXT_TITLE;
          
    $this->description MODULE_SHIPPING_ZONES_TEXT_DESCRIPTION;
          
    $this->sort_order MODULE_SHIPPING_ZONES_SORT_ORDER;
          
    $this->icon '';
          
    $this->tax_class MODULE_SHIPPING_ZONES_TAX_CLASS;
          
    $this->tax_basis MODULE_SHIPPING_ZONES_TAX_BASIS;

          
    // disable only when entire cart is free shipping
          
    if (zen_get_shipping_enabled($this->code)) {
            
    $this->enabled = ((MODULE_SHIPPING_ZONES_STATUS == 'True') ? true false);
          }

          
    // CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED
          
    $this->num_zones 6;
        }

    // 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;

          for (
    $i=1$i<=$this->num_zones$i++) {
            
    $countries_table constant('MODULE_SHIPPING_ZONES_COUNTRIES_' $i);
            
    $countries_table strtoupper(str_replace(' '''$countries_table));
            
    $country_zones split("[,]"$countries_table);
            if (
    in_array($dest_country$country_zones)) {
              
    $dest_zone $i;
              break;
            }
            if (
    in_array('00'$country_zones)) {
              
    $dest_zone $i;
              break;
            }
          }

          if (
    $dest_zone == 0) {
            
    $error true;
          } else {
            
    $shipping = -1;
            
    $zones_cost constant('MODULE_SHIPPING_ZONES_COST_' $dest_zone);

            
    $zones_table split("[:,]" $zones_cost);
            
    $size sizeof($zones_table);
            
    $done false;
            for (
    $i=0$i<$size$i+=2) {
              switch (
    MODULE_SHIPPING_ZONES_METHOD) {
                  case (
    MODULE_SHIPPING_ZONES_METHOD == 'Weight'):
                  if (
    round($shipping_weight,9) <= $zones_table[$i]) {
                    
    $shipping $zones_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_ZONES_TEXT_UNITS ')';
                      break;
                    default:
                      
    $show_box_weight ' (' $shipping_num_boxes ' x ' number_format($shipping_weight,2) . MODULE_SHIPPING_ZONES_TEXT_UNITS ')';
                      break;
                    }

    //                $shipping_method = MODULE_SHIPPING_ZONES_TEXT_WAY . ' ' . $dest_country . (SHIPPING_BOX_WEIGHT_DISPLAY >= 2 ? ' : ' . $shipping_weight . ' ' . MODULE_SHIPPING_ZONES_TEXT_UNITS : '');
                    
    $shipping_method MODULE_SHIPPING_ZONES_TEXT_WAY ' ' $dest_country $show_box_weight;
                    
    $done true;
                    break;
                    }
                  break;
                  case (
    MODULE_SHIPPING_ZONES_METHOD == 'Price'):
    // shipping adjustment
                  
    if (($_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices()) <= $zones_table[$i]) {
                    
    $shipping $zones_table[$i+1];
                    
    $shipping_method MODULE_SHIPPING_ZONES_TEXT_WAY ' ' $dest_country;
                    
    $done true;
                    break;
                    }
                  break;
                  case (
    MODULE_SHIPPING_ZONES_METHOD == 'Item'):
    // shipping adjustment
                  
    if (($total_count $_SESSION['cart']->free_shipping_items()) <= $zones_table[$i]) {
                    
    $shipping $zones_table[$i+1];
                    
    $shipping_method MODULE_SHIPPING_ZONES_TEXT_WAY ' ' $dest_country;
                    
    $done true;
                    break;
                    }
                  break;
              }
              if (
    $done == true) {
                break;
              }
            }

            if (
    $shipping == -1) {
              
    $shipping_cost 0;
              
    $shipping_method MODULE_SHIPPING_ZONES_UNDEFINED_RATE;
            } else {
              switch (
    MODULE_SHIPPING_ZONES_METHOD) {
                  case (
    MODULE_SHIPPING_ZONES_METHOD == 'Weight'):
                  
    // charge per box when done by Price
                  
    $shipping_cost = ($shipping $shipping_num_boxes) + constant('MODULE_SHIPPING_ZONES_HANDLING_' $dest_zone);
                  break;
                  case (
    MODULE_SHIPPING_ZONES_METHOD == 'Price'):
                  
    // don't charge per box when done by Price
                  
    $shipping_cost = ($shipping) + constant('MODULE_SHIPPING_ZONES_HANDLING_' $dest_zone);
                break;
                  case (
    MODULE_SHIPPING_ZONES_METHOD == 'Item'):
                  
    // don't charge per box when done by Item
                  
    $shipping_cost = ($shipping) + constant('MODULE_SHIPPING_ZONES_HANDLING_' $dest_zone);
                break;
              }
            }
          }
          
    $this->quotes = array('id' => $this->code,
                                
    'module' => MODULE_SHIPPING_ZONES_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_ZONES_SKIPPED$dest_country)) {
            
    // don't show anything for this country
            
    $this->quotes = array();
          } else {
            if (
    $error == true$this->quotes['error'] = MODULE_SHIPPING_ZONES_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_ZONES_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_ZONES_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_ZONES_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_ZONES_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_ZONES_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_ZONES_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_ZONES_SKIPPED', '', 'Disable for the following Countries:', '6', '0', 'zen_cfg_textarea(', now())");

          for (
    $i 1$i <= $this->num_zones$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_ZONES_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_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/prices. Example: 3:8.50,7:10.50,... Weight/Price less than or equal to 3 would cost 8.50 for Zone " $i " destinations.', '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_ZONES_HANDLING_" $i."', '0', 'Handling Fee for this shipping zone', '6', '0', now())");
          }
        }

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

        function 
    keys() {
          
    $keys = array('MODULE_SHIPPING_ZONES_STATUS''MODULE_SHIPPING_ZONES_METHOD''MODULE_SHIPPING_ZONES_TAX_CLASS''MODULE_SHIPPING_ZONES_TAX_BASIS''MODULE_SHIPPING_ZONES_SORT_ORDER''MODULE_SHIPPING_ZONES_SKIPPED');

          for (
    $i=1$i<=$this->num_zones$i++) {
            
    $keys[] = 'MODULE_SHIPPING_ZONES_COUNTRIES_' $i;
            
    $keys[] = 'MODULE_SHIPPING_ZONES_COST_' $i;
            
    $keys[] = 'MODULE_SHIPPING_ZONES_HANDLING_' $i;
          }

          return 
    $keys;
        }
      }
    ?>

  5. #5

    Default Re: Can I duplicate the zones module?

    I make changes and get zones1.php:

    PHP Code:
    <?php
    /**
     * @package shippingMethod
     * @copyright Copyright 2003-2006 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: zones.php 4805 2006-10-22 02:32:33Z ajeh $
     */
    /*

      USAGE
      By default, the module comes with support for 3 zones.  This can be
      easily changed by editing the line below in the zones constructor
      that defines $this->num_zones.

      Next, you will want to activate the module by going to the Admin screen,
      clicking on Modules, then clicking on Shipping.  A list of all shipping
      modules should appear.  Click on the green dot next to the one labeled
      zones.php.  A list of settings will appear to the right.  Click on the
      Edit button.

      PLEASE NOTE THAT YOU WILL LOSE YOUR CURRENT SHIPPING RATES AND OTHER
      SETTINGS IF YOU TURN OFF THIS SHIPPING METHOD.  Make sure you keep a
      backup of your shipping settings somewhere at all times.

      If you want an additional handling charge applied to orders that use this
      method, set the Handling Fee field.

      Next, you will need to define which countries are in each zone.  Determining
      this might take some time and effort.  You should group a set of countries
      that has similar shipping charges for the same weight.  For instance, when
      shipping from the US, the countries of Japan, Australia, New Zealand, and
      Singapore have similar shipping rates.  As an example, one of my customers
      is using this set of zones:
        1: USA
        2: Canada
        3: Austria, Belgium, Great Britain, France, Germany, Greenland, Iceland,
           Ireland, Italy, Norway, Holland/Netherlands, Denmark, Poland, Spain,
           Sweden, Switzerland, Finland, Portugal, Israel, Greece
        4: Japan, Australia, New Zealand, Singapore
        5: Taiwan, China, Hong Kong

      When you enter these country lists, enter them into the Zone X Countries
      fields, where "X" is the number of the zone.  They should be entered as
      two character ISO country codes in all capital letters.  They should be
      separated by commas with no spaces or other punctuation. For example:
        1: US
        2: CA
        3: AT,BE,GB,FR,DE,GL,IS,IE,IT,NO,NL,DK,PL,ES,SE,CH,FI,PT,IL,GR
        4: JP,AU,NZ,SG
        5: TW,CN,HK

      Now you need to set up the shipping rate tables for each zone.  Again,
      some time and effort will go into setting the appropriate rates.  You
      will define a set of weight ranges and the shipping price for each
      range.  For instance, you might want an order than weighs more than 0
      and less than or equal to 3 to cost 5.50 to ship to a certain zone.
      This would be defined by this:  3:5.5

      You should combine a bunch of these rates together in a comma delimited
      list and enter them into the "Zone X Shipping Table" fields where "X"
      is the zone number.  For example, this might be used for Zone 1:
        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,
        12:19.1,13:20.55,14:22,15:23.45

      The above example includes weights over 0 and up to 15.  Note that
      units are not specified in this explanation since they should be
      specific to your locale.

      CAVEATS
      At this time, it does not deal with weights that are above the highest amount
      defined.  This will probably be the next area to be improved with the
      module.  For now, you could have one last very high range with a very
      high shipping rate to discourage orders of that magnitude.  For
      instance:  999:1000

      If you want to be able to ship to any country in the world, you will
      need to enter every country code into the Country fields. For most
      shops, you will not want to enter every country.  This is often
      because of too much fraud from certain places. If a country is not
      listed, then the module will add a $0.00 shipping charge and will
      indicate that shipping is not available to that destination.
      PLEASE NOTE THAT THE ORDER CAN STILL BE COMPLETED AND PROCESSED!

      It appears that the osC shipping system automatically rounds the
      shipping weight up to the nearest whole unit.  This makes it more
      difficult to design precise shipping tables.  If you want to, you
      can hack the shipping.php file to get rid of the rounding.

      Lastly, there is a limit of 255 characters on each of the Zone
      Shipping Tables and Zone Countries.

    */

      
    class zones1 {
        var 
    $code$title$description$enabled$num_zones;

    // class constructor
        
    function zones() {
          
    $this->code 'zones';
          
    $this->title MODULE_SHIPPING_ZONES_TEXT_TITLE_1;
          
    $this->description MODULE_SHIPPING_ZONES_TEXT_DESCRIPTION_1;
          
    $this->sort_order MODULE_SHIPPING_ZONES_SORT_ORDER_1;
          
    $this->icon '';
          
    $this->tax_class MODULE_SHIPPING_ZONES_TAX_CLASS_1;
          
    $this->tax_basis MODULE_SHIPPING_ZONES_TAX_BASIS_1;

          
    // disable only when entire cart is free shipping
          
    if (zen_get_shipping_enabled($this->code)) {
            
    $this->enabled = ((MODULE_SHIPPING_ZONES_STATUS_1 == 'True') ? true false);
          }

          
    // CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED
          
    $this->num_zones 6;
        }

    // 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;

          for (
    $i=1$i<=$this->num_zones$i++) {
            
    $countries_table constant('MODULE_SHIPPING_ZONES_COUNTRIES_' $i);
            
    $countries_table strtoupper(str_replace(' '''$countries_table));
            
    $country_zones split("[,]"$countries_table);
            if (
    in_array($dest_country$country_zones)) {
              
    $dest_zone $i;
              break;
            }
            if (
    in_array('00'$country_zones)) {
              
    $dest_zone $i;
              break;
            }
          }

          if (
    $dest_zone == 0) {
            
    $error true;
          } else {
            
    $shipping = -1;
            
    $zones_cost constant('MODULE_SHIPPING_ZONES_COST_' $dest_zone);

            
    $zones_table split("[:,]" $zones_cost);
            
    $size sizeof($zones_table);
            
    $done false;
            for (
    $i=0$i<$size$i+=2) {
              switch (
    MODULE_SHIPPING_ZONES_METHOD_1) {
                  case (
    MODULE_SHIPPING_ZONES_METHOD_1 == 'Weight'):
                  if (
    round($shipping_weight,9) <= $zones_table[$i]) {
                    
    $shipping $zones_table[$i+1];

                    switch (
    SHIPPING_BOX_WEIGHT_DISPLAY_1) {
                    case (
    0):
                      
    $show_box_weight '';
                      break;
                    case (
    1):
                      
    $show_box_weight ' (' $shipping_num_boxes ' ' TEXT_SHIPPING_BOXES_1 ')';
                      break;
                    case (
    2):
                      
    $show_box_weight ' (' number_format($shipping_weight $shipping_num_boxes,2) . MODULE_SHIPPING_ZONES_TEXT_UNITS_1 ')';
                      break;
                    default:
                      
    $show_box_weight ' (' $shipping_num_boxes ' x ' number_format($shipping_weight,2) . MODULE_SHIPPING_ZONES_TEXT_UNITS_1 ')';
                      break;
                    }

    //                $shipping_method = MODULE_SHIPPING_ZONES_TEXT_WAY_1 . ' ' . $dest_country . (SHIPPING_BOX_WEIGHT_DISPLAY_1 >= 2 ? ' : ' . $shipping_weight . ' ' . MODULE_SHIPPING_ZONES_TEXT_UNITS_1 : '');
                    
    $shipping_method MODULE_SHIPPING_ZONES_TEXT_WAY_1 ' ' $dest_country $show_box_weight;
                    
    $done true;
                    break;
                    }
                  break;
                  case (
    MODULE_SHIPPING_ZONES_METHOD_1 == 'Price'):
    // shipping adjustment
                  
    if (($_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices()) <= $zones_table[$i]) {
                    
    $shipping $zones_table[$i+1];
                    
    $shipping_method MODULE_SHIPPING_ZONES_TEXT_WAY_1 ' ' $dest_country;
                    
    $done true;
                    break;
                    }
                  break;
                  case (
    MODULE_SHIPPING_ZONES_METHOD == 'Item'):
    // shipping adjustment
                  
    if (($total_count $_SESSION['cart']->free_shipping_items()) <= $zones_table[$i]) {
                    
    $shipping $zones_table[$i+1];
                    
    $shipping_method MODULE_SHIPPING_ZONES_TEXT_WAY_1 ' ' $dest_country;
                    
    $done true;
                    break;
                    }
                  break;
              }
              if (
    $done == true) {
                break;
              }
            }

            if (
    $shipping == -1) {
              
    $shipping_cost 0;
              
    $shipping_method MODULE_SHIPPING_ZONES_UNDEFINED_RATE_1;
            } else {
              switch (
    MODULE_SHIPPING_ZONES_METHOD_1) {
                  case (
    MODULE_SHIPPING_ZONES_METHOD_1 == 'Weight'):
                  
    // charge per box when done by Price
                  
    $shipping_cost = ($shipping $shipping_num_boxes) + constant('MODULE_SHIPPING_ZONES_HANDLING_' $dest_zone);
                  break;
                  case (
    MODULE_SHIPPING_ZONES_METHOD_1 == 'Price'):
                  
    // don't charge per box when done by Price
                  
    $shipping_cost = ($shipping) + constant('MODULE_SHIPPING_ZONES_HANDLING_' $dest_zone);
                break;
                  case (
    MODULE_SHIPPING_ZONES_METHOD_1 == 'Item'):
                  
    // don't charge per box when done by Item
                  
    $shipping_cost = ($shipping) + constant('MODULE_SHIPPING_ZONES_HANDLING_' $dest_zone);
                break;
              }
            }
          }
          
    $this->quotes = array('id' => $this->code,
                                
    'module' => MODULE_SHIPPING_ZONES_TEXT_TITLE_1,
                                
    '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_ZONES_SKIPPED_1$dest_country)) {
            
    // don't show anything for this country
            
    $this->quotes = array();
          } else {
            if (
    $error == true$this->quotes['error'] = MODULE_SHIPPING_ZONES_INVALID_ZONE_1;
          }

          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_ZONES_STATUS_1'");
            
    $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_ZONES_STATUS_1', '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_ZONES_METHOD_1', '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_ZONES_TAX_CLASS_1', '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_ZONES_TAX_BASIS_1', '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_ZONES_SORT_ORDER_1', '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_ZONES_SKIPPED_1', '', 'Disable for the following Countries:', '6', '0', 'zen_cfg_textarea(', now())");

          for (
    $i 1$i <= $this->num_zones$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_ZONES_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_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/prices. Example: 3:8.50,7:10.50,... Weight/Price less than or equal to 3 would cost 8.50 for Zone " $i " destinations.', '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_ZONES_HANDLING_" $i."', '0', 'Handling Fee for this shipping zone', '6', '0', now())");
          }
        }

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

        function 
    keys() {
          
    $keys = array('MODULE_SHIPPING_ZONES_STATUS_1''MODULE_SHIPPING_ZONES_METHOD_1''MODULE_SHIPPING_ZONES_TAX_CLASS_1''MODULE_SHIPPING_ZONES_TAX_BASIS_1''MODULE_SHIPPING_ZONES_SORT_ORDER_1''MODULE_SHIPPING_ZONES_SKIPPED_1');

          for (
    $i=1$i<=$this->num_zones$i++) {
            
    $keys[] = 'MODULE_SHIPPING_ZONES_COUNTRIES_' $i;
            
    $keys[] = 'MODULE_SHIPPING_ZONES_COST_' $i;
            
    $keys[] = 'MODULE_SHIPPING_ZONES_HANDLING_' $i;
          }

          return 
    $keys;
        }
      }
    ?>

    After all manipulations I get next in shipping modules section:



    It not worked, not intalling correctly and... absolutly empty on place of module name.

    Prompt to me please, what I do not correctly?

    I need total 3 zones.php module clones: 1. For Russian post economy small pockets (2 kg or less), 2. For Russian post Parcel post (up to 31kg with tracking), 2. Russian post fast EMS-express post (up to 31 kg - delivery time less of week worldwide, with tracking)


    I use 2 stores for selling goods:

    http://store.siberian-shop.com (photo equipment)

    and

    http://tubes.siberian-shop.com (electronic valves and other)

  6. #6

    Default Re: Can I duplicate the zones module?

    Please help.

    Mine shops because of it I do not work correctly.


  7. #7
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Can I duplicate the zones module?

    You are cloning Zone Rate zones ...

    Are you cloning this for a reason, such as to obtain more Zones?

    You can accomplish this by saving your current Zone settings to NotePad and uninstalling the Zone Rate shipping module then editing the file:
    /includes/modules/shipping/zones.php

    and reading the instructions on how to add more zones by changing the setting on:
    PHP Code:
          // CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED
          
    $this->num_zones 3
    to how many Zones you are wanting to create ...
    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!

  8. #8

    Default Re: Can I duplicate the zones module?

    I need 3 cloned modules of Zones.php. (for small pockets, for parcels, for EMS-parcels)

    I need 6 zones per one clone of Zones.php module (this is not the problem - I know how make 1...2...or 8 zones).

    I cloned additional module by coping and rename and it not work.

  9. #9
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Can I duplicate the zones module?

    In cloning, you need to change the base name, constants, etc. in a pattern:

    class zones {
    class zones1 {

    MODULE_SHIPPING_ZONES_TEXT_TITLE
    MODULE_SHIPPING_ZONES1_TEXT_TITLE

    MODULE_SHIPPING_ZONES_TAX_CLASS
    MODULE_SHIPPING_ZONES1_TAX_CLASS

    MODULE_SHIPPING_ZONES_METHOD
    MODULE_SHIPPING_ZONES1_METHOD

    You are placing the change to these on the end rather than where it belongs ...

    You might search on:
    clone flat
    clone item

    to see other examples of cloning shipping modules ...
    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!

  10. #10

    Default Re: Can I duplicate the zones module?

    Hello Ajeh.
    Thank you.

    After correct remaking - modules worked prefect!!!

    THX!!!

    There was one small problem.
    The module 1 is intended for economic packages in weight to 2 kg, the module 2 intended for parcels and by weight to 20 kg, the module 3 is intended for (EMS) express parcels in weight to 31 kgs.
    BUT! If the buyer chooses a thing, in weight more than 2 kg at it all the same remains possibility to choose As payment module 1 (econom), and in this case price of delivery it is deduced 0$. Whether It is possible to limit the maximum weight for each module separately? Or in this version ZEN it is impossible?

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Can I duplicate the Table Rate module?
    By SquareDorito in forum Built-in Shipping and Payment Modules
    Replies: 10
    Last Post: 3 Jul 2013, 02:41 PM
  2. Duplicate zones shipping module dose not work
    By joe1joe1 in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 23 Dec 2010, 04:13 PM
  3. Duplicate zones shipping module
    By Blkpower in forum Built-in Shipping and Payment Modules
    Replies: 6
    Last Post: 23 Dec 2010, 10:39 AM
  4. Zones module: Can I create shipping zones for different states?
    By Lisa in Vermont in forum Built-in Shipping and Payment Modules
    Replies: 6
    Last Post: 31 Dec 2008, 06:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg