♥kymation Posted December 19, 2009 Share Posted December 19, 2009 (edited) This addon (addons.oscommerce.com/info/7169) calculates shipping from the location closest to the customer. There is no limit to the number of shipping locations that may be used. The closest shipper is calculated by the Great Circle distance based on Zip/Postcode. It requires a database listing the Zip/Postcodes and their latitude and longitude for the country/countries that you will be shipping to/from. A current US Zip code database is included. I'll add the link to the download as soon as it's up. Regards Jim Edited December 19, 2009 by Jan Zonjee added link Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
♥kymation Posted December 19, 2009 Author Share Posted December 19, 2009 The download is here. For the three people who will use this. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
bcmiw330 Posted May 6, 2010 Share Posted May 6, 2010 I think the download is missing a file Warning: main() [function.include]: Failed opening ......../includes/languages/english/modules/shipping/upsxml.php' and you have a call to xml 5.php and i didnt see that file either... let me know when you have a chance....great work on the contribution! Quote Link to comment Share on other sites More sharing options...
♥kymation Posted May 6, 2010 Author Share Posted May 6, 2010 The UPS module is only included for reference. If you are not using UPS, feel free to remove it from your server. You will still need to modify whatever module you are going to be using. If you are using UPS, you should install the UPSXML module files before you install Closest Shipper. See Appendix B in the manual for instructions. Yes, I probably need to add a warning to the manual, since it's not that clear. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
bcmiw330 Posted May 6, 2010 Share Posted May 6, 2010 I ran into a issue where the array was undefined/blank when it came back from the zipcode class I had to move up outside the while the new array maybe this might help someone else..great function!! Needed it for a while now! //new idea need to move $result outside while $result = array(); $distance = 24901.55; while ($closest = tep_db_fetch_array ($closest_query) ) { $new_distance = $this->get_distance ($closest['postcode'], $destination_postcode); //old $result = array(); //WAS ON LINE 363? or SO switch (true) { case ($new_distance === false): // There was an error, so ignore this data break; case ($new_distance === 0): // Can't get any closer than that. Return this shipper's information $result['city'] = $closest['city_name']; $result['state'] = $closest['state_id']; $result['country'] = $closest['country_id']; $result['postcode'] = $closest['postcode']; return $result; break; case ($new_distance < $distance): Quote Link to comment Share on other sites More sharing options...
bcmiw330 Posted May 6, 2010 Share Posted May 6, 2010 Thanks Jim!! WORKS AWESOME!!! You were right the upsxml module was what was giving me a headache and then I figured out rather quickly the problem I had with the array! Quote Link to comment Share on other sites More sharing options...
♥kymation Posted May 6, 2010 Author Share Posted May 6, 2010 Thanks for the bug report. I'll add your fix to the next release. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
phi148 Posted June 11, 2016 Share Posted June 11, 2016 Hi Jim, I almost have this ready... i think I'm getting closer. I also use MVS and I'm running 2.3.4. It appears in my MVS shipping module I need to call: the "closest" function passing both the destination zip code and the vendors ID. When I do that, I get the following error in my server logs: [11-Jun-2016 15:23:58 America/Chicago] PHP Warning: mysql_query(): Access denied for user 'root'@'localhost' (using password: NO) in /home/xxxxx/public_html/includes/classes/zipcode.class.php on line 168 [11-Jun-2016 15:23:58 America/Chicago] PHP Warning: mysql_query(): A link to the server could not be established in /home/xxxxx/public_html/includes/classes/zipcode.class.php on line 168 Line 168 is in the "get_zip_point" function and is specifically this call: $r = mysql_query($sql); Any thoughts? Thanks! Quote Link to comment Share on other sites More sharing options...
phi148 Posted June 11, 2016 Share Posted June 11, 2016 Looking further, seems like deprecated mysql calls... Hmm... any thoughts on what the zipcode.class.php should look like with the new calls? Quote Link to comment Share on other sites More sharing options...
♥kymation Posted June 11, 2016 Author Share Posted June 11, 2016 Wow that code is bad. Sorry, I didn't remember it as being this awful. Try changing this mess: $r = mysql_query($sql); if (!$r) { $this->last_error = mysql_error(); return false; } else { $row = mysql_fetch_array($r); mysql_free_result($r); return $row; } to this: $r = tep_db_query($sql); if (!$r) { return false; } else { $row = tep_db_fetch_array($r); tep_db_free_result($r); return $row; } Please let me know if that helps. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
phi148 Posted June 11, 2016 Share Posted June 11, 2016 Wow that code is bad. Sorry, I didn't remember it as being this awful. Try changing this mess: $r = mysql_query($sql); if (!$r) { $this->last_error = mysql_error(); return false; } else { $row = mysql_fetch_array($r); mysql_free_result($r); return $row; } to this: $r = tep_db_query($sql); if (!$r) { return false; } else { $row = tep_db_fetch_array($r); tep_db_free_result($r); return $row; } Please let me know if that helps. Regards Jim Thanks for the super fast reply Jim! No luck yet... I'll keep debugging and let you know what I find. Thank you sir!! 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.