Philip79 Posted April 1, 2007 Share Posted April 1, 2007 First of all thank you for this contribution Skittles. I am migrating over from Microsoft bCentral and your contribution was what I was looking for my US based shipping needs. I am using this in conjunction with another contribution "Additional Shipping Options for Zone Module" as I also ship internationally but use a standard rate amount based upon order cost and then adjust through my payment gateway the actual shipping and handling cost. One item that I would like to change is the interstate.php code and the supporting english language file is from shipping weight and lb(s) to something like Order Cost or perhaps I could just remove that portion of code from the interstate.php. Before I just go and remove code, I wanted to verify that it would not cause any harm. That would involve modifying to display the price range from the zone rate or just delete those lines of code in the $shipping_method display statement and remove shipping_weight and INTERSTATE_TEXT_UNITS. I would appreciate your suggestion. Again thanks for the contruibution and your assistance. Philip Quote Link to comment Share on other sites More sharing options...
♥Skittles Posted April 1, 2007 Author Share Posted April 1, 2007 First of all thank you for this contribution Skittles. I am migrating over from Microsoft bCentral and your contribution was what I was looking for my US based shipping needs. I am using this in conjunction with another contribution "Additional Shipping Options for Zone Module" as I also ship internationally but use a standard rate amount based upon order cost and then adjust through my payment gateway the actual shipping and handling cost. One item that I would like to change is the interstate.php code and the supporting english language file is from shipping weight and lb(s) to something like Order Cost or perhaps I could just remove that portion of code from the interstate.php. Before I just go and remove code, I wanted to verify that it would not cause any harm. That would involve modifying to display the price range from the zone rate or just delete those lines of code in the $shipping_method display statement and remove shipping_weight and INTERSTATE_TEXT_UNITS. I would appreciate your suggestion. Again thanks for the contruibution and your assistance. Philip Philip, PM me your email address, and I'll email you modified code and instructions to support it. The modification uses the order total (before taxes), rather than shipping weight, to determine shipping charges. Sounds like it is just what you need. -Skittles Quote Link to comment Share on other sites More sharing options...
Philip79 Posted April 1, 2007 Share Posted April 1, 2007 Philip, PM me your email address, and I'll email you modified code and instructions to support it. The modification uses the order total (before taxes), rather than shipping weight, to determine shipping charges. Sounds like it is just what you need. -Skittles Thanks for your quick reply. Sounds like just what I need. I am a programmer, from years ago, but not PHP so I understand what I am reading but not necessarily the syntax and commands yet. Email address is philip@sheersox.com Again thanks. Quote Link to comment Share on other sites More sharing options...
marbury1 Posted May 15, 2007 Share Posted May 15, 2007 Leslie, A simple change in the module will allow you to use the order total instead of weight. I modified the module for three zones with this change and tested it on my development server. PM me your email address and I'll send you the file. You'll still need to make your changes based on what states go into which of the three zones. The additional values you were seeing are controlled in Admin->Configuration->Shipping/Packaging. "Enter the Maximum Package Weight you will ship": 50 by default. Divides the weight total into multiple packages of 50 each. The code then multiplies the shipping cost for 50 by the resulting "number of packages". "Package Tare weight": 3 by default. Weight of packaging over and above the weight of the product(s). Value is added to weight. "Larger packages - percentage increase": 10 by default. Multiplies the cost by 10 percent. However, if you use the modified version of Zone Shipping by State that I'm sending you, and remove the values you put in the product weight field, you won't need to make any changes in the these options. On the other hand, if you enter real weights in the product weight field so that you can use other shipping modules, you'll need to adjust these values accordingly. You should modify the product weight field, removing the price values. Here's a quick and easy way, if you have access to phpMyAdmin for your database: Open phpMyAdmin. Open your database by selecting it from the drop-down menu on the left. In the right frame, look for a tab labeled "SQL" and click on it There should be a text entry field, with the label "Run SQL query/queries on database" followed by the name of your database. Cut and paste the following two commands into the text field and click on the "Go" button. ALTER TABLE `products` DROP `products_weight`; ALTER TABLE `products` ADD `products_weight` decimal(5,2) NOT NULL default '0' AFTER `products_date_available`; This will first remove the field from the table, then add the field back into the table with a value of zero. If you will be using the actual weights, you will need to go back in and add them, but the "overweight" values of the product prices will not affect your shipping costs in the meantime. Talk to you soon, -Skittles Hello Skittles, I am wondering if you could share your, "file that allows me to use the order total instead of weight for your Zone Shipping by State Contribution. I would very much appreciate it. I am an ASP programmer trying to figure out PHP and you have been so much help already as I read through this thread. Thanks so much in advance, My email: info@cogentisolutions.com Quote Link to comment Share on other sites More sharing options...
♥Skittles Posted May 15, 2007 Author Share Posted May 15, 2007 Hello Skittles,I am wondering if you could share your, "file that allows me to use the order total instead of weight for your Zone Shipping by State Contribution. I would very much appreciate it. I am an ASP programmer trying to figure out PHP and you have been so much help already as I read through this thread. Thanks so much in advance, My email: info@cogentisolutions.com marbury1, I just emailed you an archive with the modified file, supporting language file, and instructions. If they don't arrive, let me know. -Skittles Quote Link to comment Share on other sites More sharing options...
sean4u Posted October 20, 2007 Share Posted October 20, 2007 Hi all, I was just checking the code - I had the 'Invalid region' problem (not sure I've got the error message right). It was caused by a region with a space in its name. In includes/modules/shipping/interstate.php, you use a split() function with a "[ ,]" split sequence. That's a regular expression that means split on 'either space or comma'. The square brackets mean 'any 1 of the characters inside'. Because the zones are contained in single strings, there's no way for the split function to know the difference between an in-zone-name space and a between-zone-names space, so my 'two parts' zone was being split into 'two' and 'parts'. The easy fix (I used) is to make sure that the list of zone names will be separated by a comma+space separator, and change the split statement to: $state_zones = split(", ", $state_table); // comma+space An alternative would be to separate the list of zone names by comma only, and use: $state_zones = split(",", $state_table); //comma only Hope this helps. This module is exactly what I've been wasting the last few hours trying to bend the 'Zone shipping' into. I spotted a few more changes I'd like to make to it, if I ever get round to it, I'll post them here! Thanks for contributing! Sean Quote Link to comment Share on other sites More sharing options...
♥Skittles Posted November 16, 2007 Author Share Posted November 16, 2007 Hi all, I was just checking the code - I had the 'Invalid region' problem (not sure I've got the error message right). It was caused by a region with a space in its name. In includes/modules/shipping/interstate.php, you use a split() function with a "[ ,]" split sequence. That's a regular expression that means split on 'either space or comma'. The square brackets mean 'any 1 of the characters inside'. Because the zones are contained in single strings, there's no way for the split function to know the difference between an in-zone-name space and a between-zone-names space, so my 'two parts' zone was being split into 'two' and 'parts'. The easy fix (I used) is to make sure that the list of zone names will be separated by a comma+space separator, and change the split statement to: $state_zones = split(", ", $state_table); // comma+space An alternative would be to separate the list of zone names by comma only, and use: $state_zones = split(",", $state_table); //comma only Hope this helps. This module is exactly what I've been wasting the last few hours trying to bend the 'Zone shipping' into. I spotted a few more changes I'd like to make to it, if I ever get round to it, I'll post them here! Thanks for contributing! Sean Hi Sean, Sorry to take so long to reply. I really like your solution, making the split on comma+space. The alternative you listed won't work if there is a space after the comma in the tables. It leaves a leading space on the zone name and then it always comes up as an invalid zone for all but the first entry in the table. The original zones contribution doesn't put a space between the comma and the next entry, and the display in the admin doesn't wrap. With a long list of zones, or rates, the right column pushes in on the middle section. And if it's really long, it pushes off the screen to the right forcing one to use horizontal scroll to see all the values. Annoyed me to no end, so I added the spaces... I'm sorry you wasted time with the original zones shipping module before you found this one. And I'm glad you like the contribution. -Skittles Quote Link to comment Share on other sites More sharing options...
adw49 Posted November 17, 2007 Share Posted November 17, 2007 Skittles, I have installed the module as per instructions, but as soon as I select it to install I get the following error: Fatal error: Call to undefined function: keys() in /home/serescom/public_html/admin/modules.php on line 152 Any idea what I have done wrong, if anything. The only changes I made were to the number of zones, increased to 6, and made text changes. Thanks, Andy. Quote Link to comment Share on other sites More sharing options...
sean4u Posted November 17, 2007 Share Posted November 17, 2007 Fatal error: Call to undefined function: keys() in /home/serescom/public_html/admin/modules.php on line 152 You could try renaming that file (to something like modules.php.old) and copying in a good version from the archive you originally downloaded from oscommerce.com Alternatively, you could post line 152 and we could have a go at repairing it - it might not be the only broken line though! Did you edit modules.php? Quote Link to comment Share on other sites More sharing options...
adw49 Posted November 17, 2007 Share Posted November 17, 2007 You could try renaming that file (to something like modules.php.old) and copying in a good version from the archive you originally downloaded from oscommerce.com Alternatively, you could post line 152 and we could have a go at repairing it - it might not be the only broken line though! Did you edit modules.php? Sean, I uploaded the original modules.php and still got the error. Here is line 152: $key_value_query = tep_db_query("select configuration_title, configuration_value, configuration_description, use_function, set_function from " . TABLE_CONFIGURATION . " where configuration_key = '" . $module_keys[$j] . "'"); The error appears when I try to install via admin. Andy. Quote Link to comment Share on other sites More sharing options...
sean4u Posted November 17, 2007 Share Posted November 17, 2007 Sean,I uploaded the original modules.php and still got the error. Here is line 152: $key_value_query = tep_db_query("select configuration_title, configuration_value, configuration_description, use_function, set_function from " . TABLE_CONFIGURATION . " where configuration_key = '" . $module_keys[$j] . "'"); The error appears when I try to install via admin. Andy. Hello Andy, sorry, I'm not a PHP programmer, so I should have read the code more carefully. The keys() function appears 4 lines higher in modules.php, where it is assigned to $module_keys. Maybe PHP does some sort of lazy assignment? I'll RTFM, that would be useful to know. Anyway, I think that the error must be caused by the keys() function being missing from your interstate module. In my original copy of the interstate.php file, that function's at line 144 (in includes/modules/shipping). It's the last thing in the file, so it should be easy to see whether it's there or not. Maybe it's worth trying the rename-and-copy-original test with that one. Quote Link to comment Share on other sites More sharing options...
adw49 Posted November 17, 2007 Share Posted November 17, 2007 Hello Andy, sorry, I'm not a PHP programmer, so I should have read the code more carefully. The keys() function appears 4 lines higher in modules.php, where it is assigned to $module_keys. Maybe PHP does some sort of lazy assignment? I'll RTFM, that would be useful to know. Anyway, I think that the error must be caused by the keys() function being missing from your interstate module. In my original copy of the interstate.php file, that function's at line 144 (in includes/modules/shipping). It's the last thing in the file, so it should be easy to see whether it's there or not. Maybe it's worth trying the rename-and-copy-original test with that one. Sean, Here is my interstate.php file - Is it correct? Sorry I don't know how to copy the line numbers. Andy. <?php /* $Id: Interstate.php Contributed by Anita L. Cross (aka skittles) (http://www.callofthewildphoto.com) Zone Shipping: By State Within A Country Developed For USA. Can be adapted to other countries. Based on Zones.php, distributed with osCommerce MS2.2 (051113) For Use with: osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Released under the GNU General Public License */ class interstate { var $code, $title, $description, $enabled, $num_zones; // class constructor function interstate() { $this->code = 'interstate'; $this->title = INTERSTATE_TEXT_TITLE; $this->description = INTERSTATE_TEXT_DESCRIPTION; $this->sort_order = INTERSTATE_SORT_ORDER; $this->icon = ''; $this->tax_class = INTERSTATE_TAX_CLASS; $this->enabled = ((INTERSTATE_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; // if delivery is to other country, skip module in cart if ($order->delivery['country']['iso_code_2'] != 'US') return; $dest_state = $order->delivery['state']; $dest_zone = 0; $error = false; for ($i=1; $i<=$this->num_zones; $i++) { $state_table = constant('INTERSTATE_STATES_' . $i); $state_zones = split("[ ,]", $state_table); if (in_array($dest_state, $state_zones)) { $dest_zone = $i; break; } } if ($dest_zone == 0) { $error = true; } else { $shipping = -1; $interstate_cost = constant('INTERSTATE_COST_' . $dest_zone); $interstate_table = split("[:,]" , $interstate_cost); $size = sizeof($interstate_table); for ($i=0; $i<$size; $i+=2) { if ($shipping_weight <= $interstate_table[$i]) { $shipping = $interstate_table[$i+1]; $shipping_method = INTERSTATE_TEXT_WAY . ' ' . $dest_state . ' : ' . $shipping_weight . ' ' . INTERSTATE_TEXT_UNITS; break; } } if ($shipping == -1) { $shipping_cost = 0; $shipping_method = INTERSTATE_UNDEFINED_RATE; } else { $shipping_cost = ($shipping * $shipping_num_boxes) + constant('INTERSTATE_HANDLING_' . $dest_zone); } } $this->quotes = array('id' => $this->code, 'module' => INTERSTATE_TEXT_SECTION_TITLE, 'methods' => array(array('id' => $this->code, 'title' => $shipping_method, 'cost' => $shipping_cost))); if ($this->tax_class > 0) { $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); } if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title); if ($error == true) $this->quotes['error'] = INTERSTATE_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 = 'INTERSTATE_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 Zones USA Method', 'INTERSTATE_STATUS', 'True', 'Offer USA specific zone rates by state?', '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, use_function, set_function, date_added) VALUES ( 'Tax Class', 'INTERSTATE_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', 'INTERSTATE_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())"); for ($i = 1; $i <= $this->num_zones; $i++) { $default_states = ''; $default_rates = ''; if ($i == 1) { $default_states = 'FL'; $default_rates = '1:11.30,2:11.50,3:11.90,4:12.40,5:12.80'; } if ($i == 2) { $default_states = 'NC, SC, GA, AL, TN'; $default_rates = '1:11.80,2:12.00,3:12.60,4:13.80,5:15.20'; } if ($i == 3) { $default_states = 'NJ, DC, MD, VA, WV, MS, KY, OH, IN, MO, LA, AR'; $default_rates = '1:12.60,2:13.70,3:15.40,4:17.30,5:19.50'; } if ($i == 4) { $default_states = 'CT, NY, PA, DE, MI, IA, NE, WI, IL, KS, OK'; $default_rates = '1:14.70,2:16.80,3:19.20,4:21.80,5:24.50'; } if ($i == 5) { $default_states = 'MA, RI, NH, VT, ME, MN, SD, NE, TX, CO, NM'; $default_rates = '1:15.30,2:18.10,3:20.80,4:23.60,5:26.40'; } if ($i == 6) { $default_states = 'ND, MT, WY, ID, UT, AZ, NV, CA, WA'; $default_rates = '1:16.10,2:18.40,3:21.20,4:24.20,5:27.40'; tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Zone " . $i ." States', 'INTERSTATE_STATES_" . $i ."', '" . $default_states . "', 'Comma separated list of two character ISO State codes that are part of Zone " . $i . ".', '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 ('Zone " . $i ." Shipping Table', 'INTERSTATE_COST_" . $i ."', '" . $default_rates . "', 'Shipping rates to Zone " . $i . " destinations based on a group of maximum order weights. Example: 3:8.50,7:10.50,... Weights less than or equal to 3 would cost 8.50 for Zone " . $i . " destinations.', '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 ('Zone " . $i ." Handling Fee', 'INTERSTATE_HANDLING_" . $i."', '5.00', 'Handling Fee for this shipping zone', '6', '0', now())"); } } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { $keys = array('INTERSTATE_STATUS', 'INTERSTATE_TAX_CLASS', 'INTERSTATE_SORT_ORDER'); for ($i=1; $i<=$this->num_zones; $i++) { $keys[] = 'INTERSTATE_STATES_' . $i; $keys[] = 'INTERSTATE_COST_' . $i; $keys[] = 'INTERSTATE_HANDLING_' . $i; } return $keys; } } } ?> Quote Link to comment Share on other sites More sharing options...
sean4u Posted November 17, 2007 Share Posted November 17, 2007 Aaaarrgghhh my eyes! No indentation... still, thanks to the wonders of gvim and its ability to select a block of code based on open and close curly brackets, I see you've misplaced a 'close curly bracket' after the $i==6 option you've added. It seems you've added it to the bottom of the file (there are 3 in a row, should only be two) to make the brackets add up right, but that encloses the keys() function inside the install() function, so it can't be accessed by other code. I hope that helps! See code fragment below. Sean Sean,Here is my interstate.php file - Is it correct? Sorry I don't know how to copy the line numbers. Andy. <?php /* $Id: Interstate.php if ($i == 5) { $default_states = 'MA, RI, NH, VT, ME, MN, SD, NE, TX, CO, NM'; $default_rates = '1:15.30,2:18.10,3:20.80,4:23.60,5:26.40'; } if ($i == 6) { $default_states = 'ND, MT, WY, ID, UT, AZ, NV, CA, WA'; $default_rates = '1:16.10,2:18.40,3:21.20,4:24.20,5:27.40'; *_*_*_*_*_*_* NO CLOSE BRACKET !!!!!!!!! *_*_*_*_*_*_*_*_ tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Zone " . $i ." States', 'INTERSTATE_STATES_" . $i ."', '" . $default_states . "', 'Comma separated list of two character ISO State codes that are part of Zone " . $i . ".', '6', '0', now())"); ... return $keys; } } } *_*_*_*_*_*_* DELETE ONE OF THESE THREE BRACKETS AT END OF FILE *_*_*_*_*_*_*_*_* Quote Link to comment Share on other sites More sharing options...
♥Skittles Posted November 18, 2007 Author Share Posted November 18, 2007 Aaaarrgghhh my eyes! No indentation... still, thanks to the wonders of gvim and its ability to select a block of code based on open and close curly brackets, I see you've misplaced a 'close curly bracket' after the $i==6 option you've added. It seems you've added it to the bottom of the file (there are 3 in a row, should only be two) to make the brackets add up right, but that encloses the keys() function inside the install() function, so it can't be accessed by other code. I hope that helps! See code fragment below. Sean ADW & Sean, Sean nailed it! The problem was the curly bracket in the wrong place. Sorry I didn't get in on this conversation. You folks are either early, early morning people or in a different time zone than me. You had this all worked out before I woke up this morning... Sean, thanks for stepping up. -Skittles Quote Link to comment Share on other sites More sharing options...
adw49 Posted November 19, 2007 Share Posted November 19, 2007 Skittles & Sean Thought I would give you an update. I corrected the '}' problem and uploaded the files again. Worked this time without any errors - thanks. Only one thing, I have already on the 'select shipping' method a 'UPS Ground' which uses the State name to determine costs by zones. If I activate the interstate shipping method, which I wanted to use for UPS 2nd day air shipping, it prevents the 'ground' option from appearing. Could I change the interstate to accept state names, instead of the abbreviation and leave the order.php file as is, or would that totally screw things up? Or is that not the reason I'm not seeing the first option? ADW Quote Link to comment Share on other sites More sharing options...
sean4u Posted November 22, 2007 Share Posted November 22, 2007 Skittles & Sean Thought I would give you an update. I corrected the '}' problem and uploaded the files again. Worked this time without any errors - thanks. Only one thing, I have already on the 'select shipping' method a 'UPS Ground' which uses the State name to determine costs by zones. If I activate the interstate shipping method, which I wanted to use for UPS 2nd day air shipping, it prevents the 'ground' option from appearing. Could I change the interstate to accept state names, instead of the abbreviation and leave the order.php file as is, or would that totally screw things up? Or is that not the reason I'm not seeing the first option? ADW Hello ADW - I'm sorry, you've got me this time! Did you try changing the 'sort order' of the shipping modules, or checking the error output from your web server? Quote Link to comment Share on other sites More sharing options...
♥Skittles Posted November 22, 2007 Author Share Posted November 22, 2007 Skittles & Sean Thought I would give you an update. I corrected the '}' problem and uploaded the files again. Worked this time without any errors - thanks. Only one thing, I have already on the 'select shipping' method a 'UPS Ground' which uses the State name to determine costs by zones. If I activate the interstate shipping method, which I wanted to use for UPS 2nd day air shipping, it prevents the 'ground' option from appearing. Could I change the interstate to accept state names, instead of the abbreviation and leave the order.php file as is, or would that totally screw things up? Or is that not the reason I'm not seeing the first option? ADW ADW, The abbreviations are more compact, but you can use the full state name. As you noted, don't make the changes to order.php. You will need to use the full state names in the zone tables. Although it isn't necessary to change the $default_states for each zone in the module before installing, it might be easier to make the change first. For example: if ($i == 1) { $default_states = 'OR, WA, CA, NV'; $default_rates = '3:8.00, 7:12.00, 99:30.00'; would become if ($i == 1) { $default_states = 'Oregon, Washington, California, Nevada'; $default_rates = '3:8.00, 7:12.00, 99:30.00'; Let us know if that solves your problem. -Skittles Quote Link to comment Share on other sites More sharing options...
Guest Posted November 27, 2007 Share Posted November 27, 2007 Skittles i use RC1 and i'm confused how to change the order.php, can i overwrite my order.php and replace it with your file? i have my states code in 4 and 5 digits is it ok to use? thanks for your great contribution Quote Link to comment Share on other sites More sharing options...
dlyxzen Posted April 28, 2008 Share Posted April 28, 2008 This module is perfect for what i need however i have an issue with it, Instead of using actual weights i use a scale system, eg: 1= a very light item, up to ten, a very heavy item This is my table for one of my states or zones 1:2.00,2:4.00,3:6.00,4:8.00,5:10.00,6:20.00,7:30.00,8:40.00,9:50.00,10:70.00 This works fine when there is only one of each item, however, if i have two of the same item, with the weight or rating of, for example 5, instead of getting $10+$10 (two items at 5 weight) i get $70 (5+5 = 10 which equals $70), this really throws the whole thing out, is there a way to make it look at each item individually ? And add the total COST instead of the total WEIGHT?! Hope somebody can help, CHEERS dlyxzen Quote Link to comment Share on other sites More sharing options...
potatocake Posted May 22, 2008 Share Posted May 22, 2008 Hi, I have just installed this contribution and need some help because I am using this for another country other than US our weight measurement is in grams/kgs instead of lbs. Any idea how to change this? Another question is that I am using product attributes to create a weight drop down box to display different types of weight per product and their costs instead of the weight box on the products page. Can this be altered to accommodate a product attribute box instead? If anyone could get back to me on this it would be much appreciated. Thank You Quote Link to comment Share on other sites More sharing options...
potatocake Posted May 22, 2008 Share Posted May 22, 2008 I have just installed this contribution and need some help because I am using this for another country other than US our weight measurement is in grams/kgs instead of lbs. Any idea how to change this? I finally figured out how to do this. Sorry I should have read more closely. Though I did come across an error Invalid Zone. What Ive done is I separated all the zones in my zones table into 3 zones in the interstate.php file as follows: //1. Within Peninsula Malaysia if ($i == 1) { $default_states = 'Johor, Kedah, Kelantan, Labuan, Melaka, Negeri Sembilan, Pahang, Perak, Perlis, Pulau Pinang, Selangor, Terengganu, Kuala Lumpur'; $default_rates = '0.5:4.50, 0.750:5.50, 1:6.50, 1.25:7.50, 1.50:8.50, 1.75:9.50, 2:10.50, 2.50:16.00, 3:18.00, 3.5:20.00, 4:22.00, 4.5:24.00, 5:26.00'; } //2. Between Peninsula and Sarawak if ($i == 2) { $default_states = 'Sarawak'; $default_rates = '0.5:6.50, 0.750:8.00, 1:9.50, 1.25:11.00, 1.50:12.50, 1.75:14.00, 2:15.50, 2.50:26.00, 3:29.50, 3.5:33.00, 4:36.50, 4.5:40.00, 5:43.50'; } //3. Between Peninsula and Sabah if ($i == 3) { $default_states = 'Sabah'; $default_rates = '0.5:7.00, 0.750:9.00, 1:11.00, 1.25:13.00, 1.50:15.00, 1.75:17.00, 2:19.00, 2.50:31.00, 3:35.00, 3.5:39.00, 4:43.00, 4.5:47.00, 5:51.00'; } I modified your interstate.php for Malaysia rates instead of US rates. I didnt change much but follow your instructions to just change the values according to my country's rates. To test, I created an the order with a shipping address containing the state of Kuala Lumpur this gave me the Invalid Zone error on the checkout_shipping page. Reading one of your old posts about checking what is passed into the module via the code: if ($error == true) $this->quotes['error'] = $dest_state; I tried this and got the value Kuala Lumpur. This is stored the same as the zone_code in the database. Is it due to the spaces? Below is the data of my zones table: zone_id zone_country_id zone_code zone_name 1 129 Johor Johor 2 129 Kedah Kedah 3 129 Kelantan Kelantan 4 129 Labuan Labuan 5 129 Melaka Melaka 6 129 Negeri Sembilan Negeri Sembilan 7 129 Pahang Pahang 8 129 Perak Perak 9 129 Perlis Perlis 10 129 Pulau Pinang Pulau Pinang 11 129 Sabah Sabah 12 129 Sarawak Sarawak 13 129 Selangor Selangor 14 129 Terengganu Terengganu 15 129 Kuala Lumpur Kuala Lumpur (Sorry about the horrible table format) Thank You in advance. Quote Link to comment Share on other sites More sharing options...
sean4u Posted May 23, 2008 Share Posted May 23, 2008 I finally figured out how to do this. Sorry I should have read more closely. ... I tried this and got the value Kuala Lumpur. This is stored the same as the zone_code in the database. Is it due to the spaces? There's an issue with the interstate code (there should be a post a couple of pages back!) with splitting the string of state names, you can fix it by choosing to split on comma-space, rather than comma, if I recall correctly. I said ages ago I'd have a go at a zoned module myself, and a problem on a site of mine that occurred yesterday pushed me into editing! There's a route through the interstate code that allows a checkout to continue without shipping being added. In my case, I'd forgotten to add one of the Malaysian states to the default_states string, so the module returned 'invalid zone', but no error. I'm not sure whether it's a feature of the original code, or whether I introduced it myself with a careless edit. I can check, if it helps. So anyway, I wrote a module that doesn't save the rates to the DB. Since part of configuring interstate requires editing the code, I thought I might as well go the whole hog and just leave the rates right in the code. It should be trivial to change the code for any zoned shipping calculation. If you're happy to use a text editor to update your zone rates, this might be a reasonable alternative. The resulting code is a little bit simpler. You can download the module from the contributions page at lolyco.com, it's called malaysiastate.zip Quote Link to comment Share on other sites More sharing options...
potatocake Posted May 23, 2008 Share Posted May 23, 2008 (edited) There's an issue with the interstate code (there should be a post a couple of pages back!) with splitting the string of state names, you can fix it by choosing to split on comma-space, rather than comma, if I recall correctly. I thought that actually fixes: Changed line 48 from $state_zones = split("[,]", $state_table); to: $state_zones = split("[ ,]", $state_table); Which does: This allows the states to be listed with a space following the comma, making it easier to read. Prior to this change, the spaces were used but any state other than the first listed resulted in an error message rather than the shipping info. Well I tried comma-space anyways and it didnt work still Invalid Zone. I think I am looking more for the solution stated below as one of my zones have two words. Any idea anyone? (or Skittles please help) Miguel, In theory, this module should work for any country. A quick look at the zones table in the oscommerce database shows shows the following zones (provinces?): 'A Coruña', 'Alava', 'Albacete', 'Alicante', 'Almeria', 'Asturias', 'Avila', 'Badajoz', 'Baleares', 'Barcelona', 'Burgos', 'Caceres', 'Cadiz', 'Cantabria', 'Castellon', 'Ceuta', 'Ciudad Real', 'Cordoba', 'Cuenca', 'Girona', 'Granada', 'Guadalajara', 'Guipuzcoa', 'Huelva', 'Huesca', 'Jaen', 'La Rioja', 'Las Palmas', 'Leon', 'Lleida', 'Lugo', 'Madrid', 'Malaga', 'Melilla', 'Murcia', 'Navarra', 'Ourense', 'Palencia', 'Pontevedra', 'Salamanca', 'Santa Cruz De Tenerife', 'Segovia', 'Sevilla', 'Soria', 'Tarragona', 'Teruel', 'Toledo', 'Valencia', 'Valladolid', 'Vizcaya', 'Zamora', 'Zaragoza', It does not include any abbreviations for these zones. If there are abbreviations, you should update your table, as using the full names can get a bit ugly in the admin. It isn't functional. If Spain's postal system doesn't use abbreviations, then we'll just have to make do. Specifically, in the Admin, I have the code set to break the list on both semi-colons and spaces, so the list can wrap and keep the column at a reasonable width. However, your zones have several names with spaces as part of the name. That would cause problems, so either the name cannot include the spaces or the code needs to be changed. Changing the code to support the space in the name is not a major issue. Mi Español es muy malo. But if I don't need to undertand Spanish to work on the site, I'd be happy to integrate this into your site. Just send me a PM with your email address (don't post it!) and I'll get back to you. -Skittles Also, has anyone tried this contribution with Add Weight To Product Attributes v0.1 contribution? Edited May 23, 2008 by potatocake Quote Link to comment Share on other sites More sharing options...
potatocake Posted May 23, 2008 Share Posted May 23, 2008 So anyway, I wrote a module that doesn't save the rates to the DB. Since part of configuring interstate requires editing the code, I thought I might as well go the whole hog and just leave the rates right in the code. It should be trivial to change the code for any zoned shipping calculation. If you're happy to use a text editor to update your zone rates, this might be a reasonable alternative. The resulting code is a little bit simpler. Thanks Sean for the contribution. Trying to install it atm, in your readme file you said: Make sure your Malaysian states are setup in Admin..Locations/Taxes..Zones Do I have to add each insert each zones individually to make it work? as it just currently displays: Country Zone Malaysia All Zones Quote Link to comment Share on other sites More sharing options...
sean4u Posted May 23, 2008 Share Posted May 23, 2008 Thanks Sean for the contribution. Trying to install it atm, in your readme file you said: Make sure your Malaysian states are setup in Admin..Locations/Taxes..Zones Do I have to add each insert each zones individually to make it work? as it just currently displays: Country Zone Malaysia All Zones Yes, you have to install each zone individually. Maybe someone could write a little piece of SQL to do it copy-and-paste, but there are only 14 states, so it's not that bad. This is how my zones page looks: Country Zones Code Malaysia Johor Johor Malaysia Kedah Kedah Malaysia Kelantan Kelantan Malaysia Kuala Lumpur Kuala Lumpur Malaysia Malacca Melaka Malaysia Negeri Sembilan Negeri Sembilan Malaysia Pahang Pahang Malaysia Penang Penang Malaysia Perak Perak Malaysia Perlis Perlis Malaysia Sabah Sabah Malaysia Sarawak Sarawak Malaysia Selangor Selangor Malaysia Terengganu Terengganu I don't know what happened to Malacca, seems to work out ok. Quote 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.