mikem Posted December 9, 2005 Posted December 9, 2005 Im having troable, as so are different store owners i know with calulating shipping cost My main concerns being weight and postal code/area. I want to set different postal rates to say different areas basied on postal cost and i want a table that factors in the weight. i have tried the module Shipping Zone Rates with SQL (http://www.oscommerce.com/community/contributions,1478/page,8) with no luck it seems to be calulating a extra value i can find and the readme isnt very help full Could anyone help me with module or offer other ways i could over come this with oscommerce Quote
Guest Posted December 20, 2005 Posted December 20, 2005 Im having troable, as so are different store owners i know with calulating shipping cost My main concerns being weight and postal code/area. I want to set different postal rates to say different areas basied on postal cost and i want a table that factors in the weight. i have tried the module Shipping Zone Rates with SQL (http://www.oscommerce.com/community/contributions,1478/page,8) with no luck it seems to be calulating a extra value i can find and the readme isnt very help full Could anyone help me with module or offer other ways i could over come this with oscommerce Could that be the tare weight setting in admin>config>shipping adding to your weight, therefore cost?. If so set it to 0 Quote
mikem Posted December 22, 2005 Author Posted December 22, 2005 ar yea forgot about that extra cost thank you am having troble now with the post cost checking i want it to reconize just the first letters and numbers but this contribution only allows you to put in the post code as a full for example my post code is DA3 4DE now for the area there a hunderds of post codes starting with DA so i only want this in the database instead of inserting all of the postal codes The modual code reads <?php/* Released under the GNU General Public License */ class tollzipzones { var $code, $title, $description, $enabled, $num_zones, $surcharge_factor; // class constructor:w function tollzipzones() { $this->code = 'tollzipzones'; $this->title = MODULE_SHIPPING_TOLLZIPZONES_TEXT_TITLE; $this->description = MODULE_SHIPPING_TOLLZIPZONES_TEXT_DESCRIPTION; $this->icon = DIR_WS_ICONS . 'toll_sml.gif'; $this->enabled = MODULE_SHIPPING_TOLLZIPZONES_STATUS; // 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'); // Change this surcharge factor to increase your profit margin on freight $this->surcharge_factor = 1.0; } // class methods function quote($method = '') { global $order, $shipping_weight, $shipping_num_boxes; // First get the dest zip and check the db for our dest zone $zip = $order->delivery['postcode']; if ( $zip == '' ){ // Something is wrong, we didn't find any zone $this->quotes['error'] = MODULE_SHIPPING_TOLLZIPZONES_NO_ZIPCODE_FOUND; return $this->quotes; } $sql = "SELECT * FROM toll_zones WHERE $zip >= t_postcode and $zip <= t_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['t_zone']; if ( $zone_id == '' ){ // Something is wrong, we didn't find any zone $this->quotes['error'] = MODULE_SHIPPING_TOLLZIPZONES_NO_ZONE_FOUND; return $this->quotes; } $sql = "SELECT t_rate FROM toll_rates WHERE t_zone_id = '$zone_id'"; $qResult = tep_db_query($sql); while ($rec = tep_db_fetch_array($qResult)) {$retArr[] = $rec;} foreach($retArr as $aquote){ $cost = $aquote['t_rate']; } $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_TOLLZIPZONES_TEXT_TITLE, 'methods' => array(array('id' => $this_code, 'title' => MODULE_SHIPPING_TOLLZIPZONES_TEXT_DESCRIPTION, 'cost' => (($cost * $this->surcharge_factor * $shipping_weight)*1.00)+ MODULE_SHIPPING_TOLLZIPZONES_HANDLING))); //1.10 added to calculate 10% GST on freight in Australia if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title); if ($error == true) $this->quotes['error'] = MODULE_SHIPPING_TOLLZIPZONES_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_TOLLZIPZONES_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, date_added) VALUES ('Enable Toll Postcode Zones Method', 'MODULE_SHIPPING_TOLLZIPZONES_STATUS', '1', 'Do you want to offer Toll postcode/zone rate shipping?', '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 ('Handling Fee', 'MODULE_SHIPPING_TOLLZIPZONES_HANDLING', '0', 'Handling Fee for this shipping method', '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_TOLLZIPZONES_STATUS', 'MODULE_SHIPPING_TOLLZIPZONES_HANDLING', ); return $keys; } } ?> Quote
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.
Note: Your post will require moderator approval before it will be visible.