Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2007
    Posts
    342
    Plugin Contributions
    7

    Default UK Postal Code Shipping module stopped working

    PHP 7.3

    For some strange reason the UK Shipping by Post Code is not loading properly. In the admin area I am not seeing the Post Code areas so I can adjust the pricing and postal codes. It would appear that they are not loading into the database.
    PHP Code:
    class ukpost {    var $code$title$description$enabled$num_zones;
        function 
    __construct() {      $this->code 'ukpost';      $this->title MODULE_SHIPPING_UKPOST_TEXT_TITLE;      $this->description MODULE_SHIPPING_UKPOST_TEXT_DESCRIPTION;      $this->sort_order defined('MODULE_SHIPPING_UKPOST_SORT_ORDER') ? MODULE_SHIPPING_UKPOST_SORT_ORDER null;      if (null === $this->sort_order) return false;      $this->icon '';      $this->tax_class MODULE_SHIPPING_UKPOST_TAX_CLASS;      $this->tax_basis MODULE_SHIPPING_UKPOST_TAX_BASIS;
          if (
    zen_get_shipping_enabled($this->code)) {        $this->enabled = ((MODULE_SHIPPING_UKPOST_STATUS == 'True') ? true false);      }
          
    // CHANGE THIS SETTING TO INCREASE THE NUMBER OF ZONES      // NOTE... Default Num Zones is set at 4      // You will need to uninstall (if already installed) and reinstall       // to have the changed zones number visible in the admin.      $this->num_zones = 4;    }    // class methods    function quote($method = '') {      global $order, $shipping_weight, $shipping_num_boxes, $total_count;      $destination_postcode = $order->delivery['postcode'];      $pcode = preg_replace('/\s\s*/', '', $destination_postcode);      $len = strlen($pcode); //echo $len."<br>";      if ($len <= 6) {$plen = 3;} else {$plen = 4;}      $destination_pcode = strtoupper(trim(mb_substr($pcode,0,$plen)));      $dest_zone = 0;      $error = false;
          
    for ($i=1$i<=$this->num_zones$i++) {        $postcode_table constant('MODULE_SHIPPING_UKPOST_CODES_' $i);        $post_zones preg_split("/[,]/"$postcode_table);        if (in_array($destination_pcode$post_zones)) {          $dest_zone $i;          break;          }                    else { $dest_zone 1;}        }        if ($order->delivery['country_id'] != 222) {$dest_zone 0;}
          if (
    $dest_zone == 0) {        $error true;      } else {        $shipping = -1;        $postage_cost constant('MODULE_SHIPPING_UKPOST_COST_' $dest_zone);        $postcode_table preg_split("/[:,]/" $postage_cost);        $size sizeof($postcode_table);        $done false;        for ($i=0$i<$size$i+=2) {          switch (MODULE_SHIPPING_UKPOST_METHOD) {              case (MODULE_SHIPPING_UKPOST_METHOD == 'Weight'):              if (round($shipping_weight,9) <= $postcode_table[$i]) {                $shipping $postcode_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_UKPOST_TEXT_UNITS ')';                  break;                default:                  $show_box_weight ' (' $shipping_num_boxes ' x ' number_format($shipping_weight,2) . MODULE_SHIPPING_UKPOST_TEXT_UNITS ')';                  break;                }
                    
    $shipping_method MODULE_SHIPPING_UKPOST_TEXT_WAY ' ' $dest_country $show_box_weight;                $done true;                break;                }              break;              case (MODULE_SHIPPING_UKPOST_METHOD == 'Price'):            // shipping adjustment              if (($_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices()) <= $postcode_table[$i]) {                $shipping = $postcode_table[$i+1];                $shipping_method = MODULE_SHIPPING_UKPOST_TEXT_WAY . ' ' . $destination_postcode;                $done = true;                break;                }              break;              case (MODULE_SHIPPING_UKPOST_METHOD == 'Item'):            // shipping adjustment              if (($total_count - $_SESSION['cart']->free_shipping_items()) <= $postcode_table[$i]) {                $shipping = $postcode_table[$i+1];                $shipping_method = MODULE_SHIPPING_UKPOST_TEXT_WAY . ' ' . $destination_postcode;                $done = true;                break;                }              break;          }          if ($done == true) {            break;          }        }        if ($shipping == -1) {          $shipping_cost = 0;          $shipping_method = MODULE_SHIPPING_UKPOST_UNDEFINED_RATE;        } else {          switch (MODULE_SHIPPING_UKPOST_METHOD) {              case (MODULE_SHIPPING_UKPOST_METHOD == 'Weight'):              // no charge per package by Price              $shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_UKPOST_HANDLING_' . $dest_zone);              break;              case (MODULE_SHIPPING_UKPOST_METHOD == 'Price'):              // no charge per package by Price              $shipping_cost = ($shipping) + constant('MODULE_SHIPPING_UKPOST_HANDLING_' . $dest_zone);            break;              case (MODULE_SHIPPING_UKPOST_METHOD == 'Item'):              // no charge per package by Item              $shipping_cost = ($shipping) + constant('MODULE_SHIPPING_UKPOST_HANDLING_' . $dest_zone);            break;          }        }      }      $this->quotes = array('id' => $this->code,                            'module' => MODULE_SHIPPING_UKPOST_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_UKPOST_INVALID_CODE;
          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_UKPOST_STATUS'");        $this->_check $check_query->RecordCount();      }      return $this->_check;    }    // Module Installation    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 PostCode Method', 'MODULE_SHIPPING_UKPOST_STATUS', 'True', '<img src=http://www.zenned.co.uk/images/logo_sm.gif><br />Do you want to include Zenned! UK postcode based 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_UKPOST_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_UKPOST_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_UKPOST_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_UKPOST_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
          
    for ($i 1$i <= $this->num_zones$i++) {        $default_postcodes '';        $description '';        $default_value '';        if ($i == 1) {          $default_postcodes 'LEAVE EMPTY';          $default_value '0.01:1.39,0.25:1.72,0.50:2.24,0.75:2.75,1.00:3.35,1.25:4.50          ,1.50:5.20,1.75:5.90,2.0:6.60,25.0:7.14,30.0:13.14,35.0:19.18';          $description 'Default Mainland Postcode Zone';        }        if ($i == 2) {          $default_postcodes ='AB31,AB32,AB33,AB34,AB35,AB36,AB37,AB38,AB40,AB41,AB42,AB43,AB44,AB45,AB46,AB47,AB48,AB49,AB50,AB51,AB52,AB53,AB54,AB55,AB56,KW1,KW2,KW3,KW4,KW5,KW6,KW7,KW8,KW9,KW10,KW11,KW12,KW13,KW14,PA21,PA22,PA23,PA24,PA25,PA26,PA27,PA28,PA29,PA30,PA31,PA32,PA33,PA34,PA35,PA36,PA37,PA38,PA39,PA40,PA41,PA45,PA46,PA47,PA48,PA49,PA20,PA42,PA43,PA44,PA60,PA61,PA62,PA63,PA64,PA65,PA66,PA67,PA68,PA69,PA70,PA71,PA72,PA73,PA74,PA75,PA76,PA77,PA78,PH17,PH18,PH19,PH20,PH21,PH22,PH23,PH24,PH25,PH26,PH30,PH31,PH32,PH33,PH34,PH35,PH36,PH37,PH38,PH39,PH40,PH41,PH42,PH43,PH44,PH49,PH50,KA27,KA28,HS1,HS2,HS3,HS4,HS5,HS6,HS7,HS8,HS9,ZE1,ZE2,ZE3,ZE4,IV1,IV2,IV3,IV4,IV5,IV6,IV7,IV8,IV9,IV10,IV11,IV12,IV13,IV14,IV15,IV16,IV17,IV18,IV19,IV20,IV21,IV22,IV23,IV24,IV25,IV26,IV27,IV28,IV29,IV30,IV3,IV32,IV33,IV34,IV35,IV36,IV37,IV38,IV39,IV40,IV41,IV42,IV43,IV44,IV45,IV46,IV47,IV48,IV49,IV50,IV51,IV52,IV53,IV54,IV55,IV56,IV57,IV58,IV59,IV60,IV61,IV62,IV63';          $default_value '0.01:1.39,0.25:1.72,0.50:2.24,0.75:2.75,1.00:3.35,1.25:4.50          ,1.50:5.20,1.75:5.90,2.0:6.60,25.0:18.45';          $description 'Scottish Highlands & Islands';        }                  if ($i == 3) {          $default_postcodes ='BT1,BT2,BT3,BT4,BT5,BT6,BT7,BT8,BT9,BT10,BT11,BT12,BT13,BT14,BT15,BT16,BT17,BT18,BT19,BT20,BT21,BT22,BT23,BT24,BT25,BT26,BT27,BT28,BT29,BT30,BT31,BT32,BT33,BT34,BT35,BT36,BT37,BT38,BT39,BT40,BT41,BT42,BT43,BT44,BT45,BT46,BT47,BT48,BT49,BT50,BT51,BT52,BT53,BT54,BT55,BT56,BT57,BT58,BT59,BT60,BT61,BT62,BT63,BT64,BT65,BT66,BT67,BT68,BT69,BT70,BT71,BT72,BT73,BT74,BT75,BT76,BT77,BT78,BT79,BT80,BT81,BT82,BT83,BT92,BT93,BT94,IM1,IM2,IM3,IM4,IM5,IM6,IM7,IM8,IM9,TR21,TR22,TR23, TR24,TR25';          $default_value '0.01:1.39,0.25:1.72,0.50:2.24,0.75:2.75,1.00:3.35,1.25:4.50          ,1.50:5.20,1.75:5.90,2.0:6.60,25.0:18.45';          $description 'Northern Ireland, Isle of Man, Isles of Scilly';        }                if ($i == 4) {          $default_postcodes 'JE1,JE2,JE3,JE4,GY1,GY2,GY3, &,GY4,GY5,GY6,GY7,GY8,GY9,GY10';          $default_value '0.01:1.39,0.25:1.72,0.50:2.24,0.75:2.75,1.00:3.35,1.25:4.50          ,1.50:5.20,1.75:5.90,2.0:6.60,25.0:22.53';          $description 'Channel Islands';        }                        $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 ." Post Codes', 'MODULE_SHIPPING_UKPOST_CODES_" $i ."', '" $default_postcodes "', 'UK Post ".$description." - Zone " $i "', '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_UKPOST_COST_" $i ."', '" .$default_value"', '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_UKPOST_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_UKPOST_STATUS''MODULE_SHIPPING_UKPOST_METHOD''MODULE_SHIPPING_UKPOST_TAX_CLASS''MODULE_SHIPPING_UKPOST_TAX_BASIS''MODULE_SHIPPING_UKPOST_SORT_ORDER''MODULE_SHIPPING_UKPOST_SKIPPED');
          for (
    $i=1$i<=$this->num_zones$i++) {        $keys[] = 'MODULE_SHIPPING_UKPOST_CODES_' $i;        $keys[] = 'MODULE_SHIPPING_UKPOST_COST_' $i;        $keys[] = 'MODULE_SHIPPING_UKPOST_HANDLING_' $i;      }
          return 
    $keys;    }  }?> 
    Any suggestion please, thank you.

  2. #2
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: UK Postal Code Shipping

    Is this "improper" loading something that just "suddenly" started happening (eg is there history with successfully using this method?) if so what changed?

    As for improper operation on the admin side, does the entire page load? For example does the zen cart footer appear on the page in question? If not, then there probably is a myDEBUG-adm- related log file in the logs folder with information about the problem... if posting such a file be sure to obscure the admin folder's name (admin works fine).
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Jul 2007
    Posts
    342
    Plugin Contributions
    7

    Default Re: UK Postal Code Shipping

    Quote Originally Posted by mc12345678 View Post
    Is this "improper" loading something that just "suddenly" started happening (eg is there history with successfully using this method?) if so what changed?

    As for improper operation on the admin side, does the entire page load? For example does the zen cart footer appear on the page in question? If not, then there probably is a myDEBUG-adm- related log file in the logs folder with information about the problem... if posting such a file be sure to obscure the admin folder's name (admin works fine).
    Thank you for your response. I have used this plugin many times, also made a few changes for PHP and submitted. It worked fine, last time was on early version of 1.5.6. The plugin appears in admin ok, just not showing the postal codes and weights and prices. It would appear that it has failed to load to database. So I was wondering if the code was ok? No admin debug.

 

 

Similar Threads

  1. v139h USPS Shipping Module Quotes Stopped Working Today?
    By ts232 in forum Built-in Shipping and Payment Modules
    Replies: 6
    Last Post: 3 Mar 2013, 10:05 PM
  2. USPS shipping module stopped working 9/9
    By gfdesigns in forum Addon Shipping Modules
    Replies: 26
    Last Post: 13 Sep 2011, 11:49 PM
  3. Shipping rate by postal code
    By bainne in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 28 Mar 2009, 02:07 AM
  4. Shipping Help Postal Code
    By odessey1 in forum Addon Shipping Modules
    Replies: 5
    Last Post: 7 Feb 2009, 12:02 AM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR