volumax Posted January 28, 2008 Share Posted January 28, 2008 (edited) Hi All, Need a some help here, I have been looking at this shipping module (needed for a UK shop). Toll Ipec Shipping by postcode and it fits the bill for whats needed, one draw back though, I am not able to get it working, I created the toll_rates and Toll_zone files for the UK. any one got a UK version. I have seen the other uk postcode courier contribs but the shop owner wants this one, easier to change the rates sql. All its doing at the moment its giving a shipping total but its always the same. regards Andy Edited January 28, 2008 by volumax Quote Literally, Laterally Thinking! If you cannot get through it, go round it. Link to comment Share on other sites More sharing options...
volumax Posted January 28, 2008 Author Share Posted January 28, 2008 (edited) Hi All, Need a some help here, I have been looking at this shipping module (needed for a UK shop). Toll Ipec Shipping by postcode and it fits the bill for whats needed, one draw back though, I am not able to get it working, I created the toll_rates and Toll_zone files for the UK. any one got a UK version. I have seen the other uk postcode courier contribs but the shop owner wants this one, easier to change the rates sql. All its doing at the moment its giving a shipping total but its always the same. regards Andy Below is the shipping file <?php /* Released under the GNU General Public License Based on TNT Australia Shipping based on postcode V2 By Jay Bonaretti Version 3.0 23 March 2006 by Brent Wesley */ class clzipzones { var $code, $title, $description, $enabled, $num_zones; // class constructor:w function clzipzones() { $this->code = 'clzipzones'; $this->title = MODULE_SHIPPING_CLZIPZONES_TEXT_TITLE; $this->description = MODULE_SHIPPING_CLZIPZONES_TEXT_DESCRIPTION; $this->icon = DIR_WS_ICONS . ''; $this->tax_class = MODULE_SHIPPING_CLZIPZONES_TAX_CLASS; $this->sort_order = MODULE_SHIPPING_CLZIPZONES_SORT_ORDER; $this->enabled = ((MODULE_SHIPPING_CLZIPZONES_STATUS == 'True') ? true : false); // Customize this setting for the number of zones needed (no change required by default) $this->num_zones = 1; //More options can be added later for Express, Overnight etc when someone codes it. $this->types = array('Toll Off-Peak' => 'std'); } // class methods function quote($method = '') { global $order, $shipping_weight, $shipping_num_boxes; //First split the destination postcode and check the db for matching delivery zone $postcode = $order->delivery['postcode']; list($c_postcode, $local) = split('[/ -]', $postcode); if ( $c_postcode == '' ){ // Something is wrong, no matching area code $this->quotes['error'] = MODULE_SHIPPING_CLZIPZONES_NO_POSTCODE; return $this->quotes; } $sql = "SELECT * FROM cl_zones WHERE c_postcode = '$c_postcode'"; $qResult = tep_db_query($sql); // run the query $rec = tep_db_fetch_array($qResult); // get the first row of the result $zone_id = $rec['c_zone']; if ( $zone_id == '' ){ // Something is wrong, we didn't find any zone $this->quotes['error'] = MODULE_SHIPPING_CLZIPZONES_NO_ZONE_FOUND; return $this->quotes; } // Consignment Rate insertion start $sql = "SELECT c_rate FROM cl_rates WHERE c_zone_id = '$zone_id'"; $qResult = tep_db_query($sql); while ($rec = tep_db_fetch_array($qResult)) {$retArr[] = $rec;} foreach($retArr as $aquote){ $cost = $aquote['c_rate']; } // Consignment Rate insertion end // Consignment charge insertion start $sql = "SELECT c_ccharge FROM cl_rates WHERE c_zone_id = '$zone_id'"; $qResult = tep_db_query($sql); while ($rec = tep_db_fetch_array($qResult)) {$retArr[] = $rec;} foreach($retArr as $aquote){ $ccharge = $aquote['c_ccharge']; } // Consignment charge insertion end //calculate the freight charge taking in the min consignment charge $tmp_charge = (($cost * $shipping_weight + $ccharge) * MODULE_SHIPPING_CLZIPZONES_FUEL); if ($tmp_charge <= $ccharge) { $freight_charge = $ccharge; } else { $freight_charge = $tmp_charge;} $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_CLZIPZONES_TEXT_TITLE, 'methods' => array(array('id' => $this_code, 'title' => MODULE_SHIPPING_CLZIPZONES_TEXT_DESCRIPTION, 'cost' => $freight_charge + MODULE_SHIPPING_CLZIPZONES_HANDLING))); if ($this->tax_class > 0) { $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); } if ($error == true) $this->quotes['error'] = MODULE_SHIPPING_CLZIPZONES_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_CLZIPZONES_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 UK City Link delivery', 'MODULE_SHIPPING_CLZIPZONES_STATUS', 'True', 'Offer UK carrier shipping by Postcode?', '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, date_added) values ('Handling Fee', 'MODULE_SHIPPING_CLZIPZONES_HANDLING', '0', 'Handling Fee for this shipping method', '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 ('Fuel Levey', 'MODULE_SHIPPING_CLZIPZONES_FUEL', '0', 'Fuel Levey', '6', '0', 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_CLZIPZONES_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_CLZIPZONES_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())"); } function remove() { $keys = ''; $keys_array = $this->keys(); for ($i=0; $i<sizeof($keys_array); $i++) { $keys .= "'" . $keys_array[$i] . "',"; } $keys = substr($keys, 0, -1); tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in (" . $keys . ")"); } function keys() { $keys = array( 'MODULE_SHIPPING_CLZIPZONES_STATUS', 'MODULE_SHIPPING_CLZIPZONES_HANDLING', 'MODULE_SHIPPING_CLZIPZONES_FUEL', 'MODULE_SHIPPING_CLZIPZONES_TAX_CLASS', 'MODULE_SHIPPING_CLZIPZONES_SORT_ORDER' ); return $keys; } } ?> Edited January 28, 2008 by volumax Quote Literally, Laterally Thinking! If you cannot get through it, go round it. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.