Jump to content



Photo
- - - - -

[Addon] Closest Shipper


  • Please log in to reply
10 replies to this topic

#1   kymation

kymation

    Code Monkey

  • Community Sponsor
  • 9,643 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 19 December 2009 - 04:37

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 by Jan Zonjee, 19 December 2009 - 08:00.
added link

See my profile for a list of my addons and ways to get support.


#2   kymation

kymation

    Code Monkey

  • Community Sponsor
  • 9,643 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 19 December 2009 - 22:07

The download is here. For the three people who will use this.

Regards
Jim

See my profile for a list of my addons and ways to get support.


#3   bcmiw330

bcmiw330
  • Members
  • 80 posts
  • Real Name:wes

Posted 06 May 2010 - 17:15

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!

#4   kymation

kymation

    Code Monkey

  • Community Sponsor
  • 9,643 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 06 May 2010 - 18:24

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

See my profile for a list of my addons and ways to get support.


#5   bcmiw330

bcmiw330
  • Members
  • 80 posts
  • Real Name:wes

Posted 06 May 2010 - 19:33

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):


#6   bcmiw330

bcmiw330
  • Members
  • 80 posts
  • Real Name:wes

Posted 06 May 2010 - 19:51

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!

#7   kymation

kymation

    Code Monkey

  • Community Sponsor
  • 9,643 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 06 May 2010 - 20:57

Thanks for the bug report. I'll add your fix to the next release.

Regards
Jim

See my profile for a list of my addons and ways to get support.


#8   phi148

phi148
  • Members
  • 187 posts
  • Real Name:Bill

Posted 11 June 2016 - 20:36

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!



#9   phi148

phi148
  • Members
  • 187 posts
  • Real Name:Bill

Posted 11 June 2016 - 20:45

Looking further, seems like deprecated mysql calls...

 

Hmm... any thoughts on what the zipcode.class.php should look like with the new calls?



#10   kymation

kymation

    Code Monkey

  • Community Sponsor
  • 9,643 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 11 June 2016 - 21:46

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


See my profile for a list of my addons and ways to get support.


#11   phi148

phi148
  • Members
  • 187 posts
  • Real Name:Bill

Posted 11 June 2016 - 21:59

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!!