Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2008
    Location
    ontario canada
    Posts
    8
    Plugin Contributions
    1

    Default new 8 zone shipping mod help Please??

    I am in the process of converting oscommerce mod that calculates shipping cost by percentage of cart amount and the zone in which you live according to SMC.

    I have converted mod and it shows up in admin fine and installs, however when the customer arives at estimated shipping cost and checkout page they receive blank page.

    When I check debug mod I receive following error:

    [09-Jul-2008 16:46:29] PHP Fatal error: Maximum execution time of 60 seconds exceeded in /home/greatcan/public_html/catalog/includes/modules/shipping/smc.php on line 113

    line 113 reads: $dest_zone = $check['shipzonecode'];

    below is the complete mod:

    ANY HELP GREATLY APPRECIATED

    Code:
     class smc {
        var $code, $title, $description, $enabled, $num_zones;
    
    // class constructor
        function smc() {
          $this->code = 'smc';
          $this->title = MODULE_SHIPPING_SMC_TEXT_TITLE;
          $this->description = MODULE_SHIPPING_SMC_TEXT_DESCRIPTION;
          $this->sort_order = MODULE_SHIPPING_SMC_SORT_ORDER;
          $this->icon = '';
          $this->tax_class = MODULE_SHIPPING_SMC_TAX_CLASS;
          $this->enabled = ((MODULE_SHIPPING_SMC_STATUS == 'True') ? true : false);
    
          // CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED
          $this->num_zones = 10;
    	  $this->num_zone_start = 2;
        }
    
    // class methods
        function quote($method = '') {
          global $order, $cart, $shipping_weight, $shipping_num_boxes;
    
          $dest_country = $order->delivery['country']['iso_code_2'];
          $dest_zone = 0;
          $error = false;
    
    		$zipcode_prefix = substr($order->delivery['postcode'],0,3);
    		global $db;
    		$check = $db->Execute("select shipzonecode from " . TABLE_SHIPZONECODE . " where '" . $zipcode_prefix . "' BETWEEN shipzonestartzip and shipzoneendzip");
            while (!$check->EOF)) {
    
    
    
    
    			$dest_zone = $check['shipzonecode'];
    
    
    
              }
    		  $check->MoveNext();
    //		echo $dest_zone;
    
    
    
    
          if ($dest_zone == 0) {
            $error = true;
          } else {
    	  
    		/* This is the Shipping Calculation Area */	  
            $shipping = -1;
            $zones_cost = constant('MODULE_SHIPPING_SMC_COST_' . $dest_zone);
    		$order_total = $cart->show_total();
            $zones_table = split("[:,]" , $zones_cost);
            $size = sizeof($zones_table);
            for ($i=0; $i<$size; $i+=2) {
              if ($order_total <= $zones_table[$i]) {
                $shipping = $zones_table[$i+1];
                $shipping_method = MODULE_SHIPPING_SMC_TEXT_WAY . ' ' . $order->delivery['postcode'];
                break;
              }
            }
    		/*End of Shipping Calculation Area */
    
            if ($shipping == -1) {
              $shipping_cost = 0;
              $shipping_method = MODULE_SHIPPING_SMC_UNDEFINED_RATE;
            } else {
    			if (strpos($shipping, "%") === false) {
    				$shipping_cost = ($shipping) + constant('MODULE_SHIPPING_SMC_HANDLING_' . $dest_zone);
    			} else {
    				$shipcost = (str_replace("%","",$shipping) / 100);
    				$shipping_cost = ($order_total * $shipcost) + constant('MODULE_SHIPPING_SMC_HANDLING_' . $dest_zone);
    			}
            }
          }
    
          $this->quotes = array('id' => $this->code,
                                'module' => MODULE_SHIPPING_SMC_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 ($error == true) $this->quotes['error'] = MODULE_SHIPPING_SMC_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_SMC_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_SMC_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, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_SMC_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, date_added) values ('Sort Order', 'MODULE_SHIPPING_SMC_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
          for ($i = $this->num_zone_start; $i <= $this->num_zones + ($this->num_zone_start - 1); $i++) {
            $default_countries = 'US';
            $db->Execute("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_SMC_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $i . ".', '6', '0', 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 ." Shipping Table', 'MODULE_SHIPPING_SMC_COST_" . $i ."', '25:6.50,500:13%,999999:5%', 'Shipping rates to Zone " . $i . " destinations based on a group of maximum order amounts. Example: 25:6.50,500:13%,999999:5%,... Amounts less than or equal to 25 would cost 6.50 for Zone " . $i . " destinations.', '6', '0', 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_SMC_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_SMC_STATUS', 'MODULE_SHIPPING_SMC_TAX_CLASS', 'MODULE_SHIPPING_SMC_SORT_ORDER');
    
          for ($i = $this->num_zone_start; $i <= $this->num_zones + ($this->num_zone_start - 1); $i++) {
            $keys[] = 'MODULE_SHIPPING_SMC_COUNTRIES_' . $i;
            $keys[] = 'MODULE_SHIPPING_SMC_COST_' . $i;
            $keys[] = 'MODULE_SHIPPING_SMC_HANDLING_' . $i;
          }
    
          return $keys;
        }
      }
    ?>
    Thanks in advance for any input

  2. #2
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: new 8 zone shipping mod help Please??

    Code:
            while (!$check->EOF)) {
    
    
    
    
    			$dest_zone = $check['shipzonecode'];
    
    
    
              }
    		  $check->MoveNext();
    
    These two lines need to be reversed. ie: the closing brace for the while() statement needs to come *after* the MoveNext() call, otherwise you end up in an endless loop.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Jan 2008
    Location
    ontario canada
    Posts
    8
    Plugin Contributions
    1

    Default Re: new 8 zone shipping mod help Please??

    thankyou mod now installs and I am able to configure but shipping charges don't show, It tells me shipping not available to selected country

    no errors show up in error log or debug mod

    Script was converted from osc mod so I am thinking it has to be a bad variable or missing function but I would think I would get a php error somewhere

    Anyone have any ideas??

    Thanks Guys in advance

  4. #4
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: new 8 zone shipping mod help Please??

    Not sure if this is the specific cause or not, but something I noticed while looking at the code you posted earlier was:
    Code:
    		$order_total = $cart->show_total();
    should be:
    Code:
            $order_total = $_SESSION['cart']->show_total();
    And you don't need $cart listed in your "global" statement earlier in the same function.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Jan 2008
    Location
    ontario canada
    Posts
    8
    Plugin Contributions
    1

    Default Re: new 8 zone shipping mod help Please??

    Thanks to Dr Byte I finally got it to work, now to only tweak it then it will be ready for distribution.

    THE FEATURES OF MOD ARE:
    1. Shipping Rate is determined by destination zone according to UPS and DHL 7 Zone zipcode freight chart. Easily
    configurable to other countries and different shipping charts.
    2. Zipcode Zone determined by MYSQL driven data base.
    3. zipcode table easily convertable to most countries
    4. handles shipping by percentage or flat rate
    5. Number of Zones are adjustable set to 7 by default
    6. Start zone is configurable 2 by default
    7. Can have more than 1 percentage or flat rate per zone
    8. handling rate can be added to each zone
    9. Mod doesn't modify any files in ZenCart.

    If interested in such a mod
    leave me a message

  6. #6
    Join Date
    Dec 2008
    Posts
    2
    Plugin Contributions
    0

    Default Re: new 8 zone shipping mod help Please??

    Did you ever get a working Mod??

    I am trying to setup the same SMC scenario

    Could really use some direction and help

  7. #7
    Join Date
    Mar 2009
    Posts
    9
    Plugin Contributions
    0

    Default Re: new 8 zone shipping mod help Please??

    Did you ever get a reply to your request for info on the modified Mod? Also using SMC so very interested.

 

 

Similar Threads

  1. Help...tried installing the Time Zone Mod
    By kenny724 in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 10 Mar 2010, 08:19 PM
  2. Modify the Zone Shipping mod to use states instead of countries?
    By TecBrat in forum Built-in Shipping and Payment Modules
    Replies: 16
    Last Post: 30 Dec 2009, 09:14 PM
  3. Zone Rates shipping help required please
    By deshojo in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 14 Aug 2008, 11:23 AM
  4. Urgent ... Need Help on Zone Shipping Module, please..
    By kcool in forum Built-in Shipping and Payment Modules
    Replies: 3
    Last Post: 5 Oct 2007, 09:41 AM
  5. New~Please Help!Combined Shipping Questions!
    By mpettei in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 16 Jul 2007, 09:01 PM

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