Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Addon] Closest Shipper


kymation

Recommended Posts

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
added link

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

Link to comment
Share on other sites

  • 4 months later...

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 6 years later...

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...