Jump to content
torinwalker

New UPS XML Shipping Module available

Recommended Posts

Hi,

 

I'm hoping someone has a solution for the following issue. I added the contributions for Country-State Selector and World Zones, which cover pretty much every place in the world. And I started getting a UPS error at checkout with the following message:

 

111286: ML is not a valid state for the specified shipment.

 

After some troubleshooting I discovered that there are 2 records for Maryland in the database. Apparently there is a Maryland, Liberia as well, and it precedes Maryland, USA in the database and has the "ML" as the abbreviated State/Province.

 

So what the script is doing, is searching the zones database table for the first instance of "Maryland" and using that record's State/Province 2-letter code for the shipping calculations. When instead, it should be looking for that match based on the zone_country_id.

 

I can probably fix this problem for the Maryland, Liberia issue by changing the name of that province in the database to "Mary-land" but I would rather get a more valid code solution because there may be other duplicate instances and there are over 4K records in that zones table. If anyone has a solution, I would greatly appreciate it.

 

Demitry


osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&geo=US&q=oscommerce

Share this post


Link to post
Share on other sites

Maryland's abbreviation in the US is MD.  If you try to select a shipping method that doesn't apply you will get an error too.  Like Ground for Singapore won't work from the US.  I think you can find the error numbers at UPS.

Edited by John W

I'm not really a dog.

Share this post


Link to post
Share on other sites

John,

 

I know, I'm from Maryland and the test-checkout I was running was using my old Maryland address. However, the UPS module is searching out the first instance of that state name in the database and this is why (ML) is displayed in the error. This is also why there are no shipping rates because there is no ML as a US state.

 

After I posted this here, I did some more searching and found this for osCMax. Apparently this is a problem and there are more duplicates in that zones table for Florida and other states.

 

http://www.oscmax.com/forums/bugs-and-problems/27232-upsxml-wont-calculate-maryland-detects-abbrev-ml.html

 

Demitry


osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&geo=US&q=oscommerce

Share this post


Link to post
Share on other sites

I switched to fedex a couple years ago, but I used the UPS xml module in the US without problems.  However, I don't ship outside the US so I removed the other countries from my database.  Never saw any duplicates for Florida from what I remember though. 


I'm not really a dog.

Share this post


Link to post
Share on other sites

@@Demitry  It appears that oscmax did fix the problem, but they didn't share the fix here. They're also violating the copyright on the osCommerce files they stole, so no surprises there. Anyway, fix the bug by changing this line:

        $zone_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_name = '" .  tep_db_input($order->delivery['state']) . "'");

to this:

        $zone_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_name = '" .  tep_db_input($order->delivery['state']) . "' and zone_country_id = '" . $order->delivery['country']['id'] . "'");

Regards

Jim


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

Share this post


Link to post
Share on other sites

@kymation

 

Jim, You're Awesome!!!

 

That was the solution I was looking for! I just installed and tested and there are no UPS errors. The UPS rates are displaying as they should for a delivery to Maryland, USA.

 

Thank you, ...and I had no idea about osCMax infringement of OSC copyright laws. I always thought them and ZenCart were just an evolved extension of OSC.

 

Demitry


osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&geo=US&q=oscommerce

Share this post


Link to post
Share on other sites

Technically, Zen Cart and oscmax are forks of osCommerce. The last time I looked, Zen was doing that legally. Oscmax seems to have removed all of the osCommerce copyright notices and substituted their own, which is not legal.

 

In any case, oscmax gets credit for this fix. Not that it isn't trivial and I would have done much the same thing, but I give them credit where credit is due.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

Hi,

 

I want to share my trouble shooting & solution for the dreaded UPS “Rating and Service” error. It could actually be one, or several different issues. I hope this helps others because I spent a lot of time trying to resolve this problem and could not find much on the Internet.

 

If you’re getting the following error at checkout for UPS, then you should read this post.

 

Rating and Service 1.0001 0 An unknown error occured while attempting to contact the UPS gateway : Rating and Service 1.0001 0 An unknown error occured while attempting to contact the UPS gateway

 

The first and easiest step is to check if your UPS User ID and Password still work on the UPS site. UPS deletes non-active accounts after 18 months. So, if you’re using drop-shipping and not shipping anything yourself via UPS, but only providing the UPS rates on your site as a courtesy to the customer, you must log into your UPS account via their site once a year to keep it active. If your account was deleted, you will need to create a new one. The UPS tech support will guide you through it.

 

If there are no issues with your UPS account & login info, then the next step is to run the debugging script. To do this you have to follow the steps in one of the following files.

 

/includes/modules/shipping/upsxml.php

 

If you’re using the Multi-Vendor Shipping (MVS) contribution:

/includes/modules/vendors_shipping/upsxml.php

 

Search the contents of the upsxml.php file for “upsxml.log” and follow the directions to create a log file and set file permissions. Then run a test checkout (partial - only to the checkout_shipping.php page). The details of this are explained in this older thread. Much respect goes to Jan Zonjee for his help there.

 

http://forums.oscommerce.com/topic/248356-ups-xml-rates-services-v124-error/

 

Download the log file and search it for errors. You are likely to have cURL errors. cURL is a command line tool for getting or sending files using URL syntax. It is used by the UPS API gateway in providing real time rates to your store site.

 

If there are no cURL errors, you should call your hosting company’s tech support and ask them if cURL is compiled into PHP for your account. If it is not, then search the upsxml.php file for “when cURL is not compiled into PHP” and follow those directions to test further.

 

If you get the cURL [60] error, then there is a line in the upsxml.php file that you can uncomment (on or around line 736 or 811, see below), then save, upload, and do a partial test checkout again. That line is:

 

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

 

If you get the cURL Error [35]: SSL connect error, then you have entered my world. I contacted UPS tech support and sent them the upsxml.log file, and this was their response:

 

The UPS API's no longer support SSL. The UPS API's now support TLS 1.0, 1.1 and 1.2. If your solution is browser based, make sure that TLS 1.2 is enabled in the security settings. If your solution is server based, you will need to write the necessary code to make this change to your security protocol.

 

So, if you have an SSL certificate installed for your store, you would have to call your hosting company’s tech support and find out what version of TLS is enabled in the server security settings. Right now, I have an SSL certificate by COMODO and my hosting company has the TLS 1.2 enabled.

 

Based on that information I found a link that provided the one-line solution that finally fixed my UPS module problem and got rid of that pesky “Rating and Service” error. Here it is:

 

https://stackoverflow.com/questions/30145089/tls-1-2-not-working-in-curl

 

And here is the line I had to add to upsxml.php I added it with the other curl_setopt options. You can just search for “curl_setopt” in the upsxml.php

 

curl_setopt($ch, CURLOPT_SSLVERSION, 6); // Integer NOT string TLS v1.2

 

Please note: the "6" is relevant to TLS 1.2 ...other versions of TLS require a different number. See the stackoverflow.com link above for what number correlates to your TLS version.

 

I hope that helps and prevents most of you from wasting as much time as I did in trying to resolve this issue.

 

 

UPS “Rating and Service”  ERROR SOLUTION SUMMARY:

 1) Login to the UPS site to make sure your account is active and do this at least once a year.

 2) Follow the directions in the upsxml.php file to run a debugging script to write to a log file.

 3) Review the log file for errors:

  • If cURL error [60] – uncomment related line (736 or 811) in upsxml.php file
  • If cURL error [35] SSL connect – call your hosting company to find out the version of TLS enabled and then add curl_setopt($ch, CURLOPT_SSLVERSION, 6); to the rest of the curl_setopt options in upsxml.php file. Then change the “6” to the number that correlates with your enabled version of TLS.

 

 

Demitry


osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&geo=US&q=oscommerce

Share this post


Link to post
Share on other sites

@DemitryI

I commend you for taking the time to explain what you have found and solutions.  Also, realizing there are more sources than just this forum for finding solutions like stackoverflow.   The curl settings come into play on multiple modules and you can see all the options and recomendations at the PHP site also http://php.net/manual/en/function.curl-setopt.php  They recomendation is "Your best bet is to not set this and let it use the default."  For what that is worth.  Some servers are not at the level of supporting TLS1.2 but it's good that you are on a server supporting that as it's where we should be.


I'm not really a dog.

Share this post


Link to post
Share on other sites

Thank John,

 

I completely agree that this cURL option should not be set as default considering that the TLS version setting will vary from one hosting company to another. However, I think it should probably be added and commented out same as the cURL [60] error, in case someone finds this in their upsxml.log Along with the details of what number to use for each of the specific TLS versions.

 

My initial issue was that UPS deleted my account for inactivity. After reviewing the upsxml.log I found that it was using my UPS login info to communicate with the UPS gateway. So, I thought this was the problem. However, after creating a new UPS account, I was still getting that error. So, I went back into that upsxml.log and found the cURL [35] error, ..and well, you know the rest.

 

The weird thing too is that every once in a while, the UPS rates would display. So, this "Rating and Service" error was not consistent.

 

Demitry

Edited by Demitry

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&geo=US&q=oscommerce

Share this post


Link to post
Share on other sites

Thanks @@Demitry for a clear set of instructions. The information is very much appreciated.

 

I would like to add one thing: If you get to the point where you find that cURL is not installed, following the “when cURL is not compiled into PHP” instructions is probably a waste of time. That method does not support HTTP 1.1, and that is required. The correct solution is to get your host to add cURL, or find a better host.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

Cool, thanks Jim,

 

I tried to use the other debugging method too, by adding the value of "1" to use_exec on line 70 of upsxml.php, but when I ran the test checkout, I got no shipping rates or anything at all displaying below the shipping section heading. I don't know if perhaps I missed doing something, but figured I would stick with resolving the cURL error issues first.

 

Demitry


osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&geo=US&q=oscommerce

Share this post


Link to post
Share on other sites

I have been getting these error messages for a long time.

 

UPSXML Rates Error: 111210: The requested service is unavailable between the selected locations. experienced by customer with id on 2016-09-11 22:40:03

 

UPSXML TimeInTransit Error: 270032: Invalid Destination Postal Code and City experienced by customer with id on 2016-09-11 22:40:02

 

Note that there are never any details reported for “customer” or “id”. UPS support asks for error reporting so that they can troubleshoot for me.

 

Can someone please be specific and comprehensive about how to set up the error reporting for shipping module UPSXML_v1_5_1 ? Can anyone decipher these errors ? 

 

I'm running osCommerce v2.3.4 (along with the USPS with dimensional support 6_52)

Share this post


Link to post
Share on other sites

@@jjlyman

In the past when I saw this error it was because the customer didn't set the state correctly, or the state reset to Alabama.  I don't think it's a UPS problem.  Look at your recent customer signups and check state vs zip.


I'm not really a dog.

Share this post


Link to post
Share on other sites

You might also look for an incompatible address for the service.  For instance, if you only do US ground and the customer is outside the US you will get an error.


I'm not really a dog.

Share this post


Link to post
Share on other sites

...just got another pair of the same errors as posted in #2438 above.  But this time, I had just previously edited the upsxml.php file (...includes/modules/shipping/upsxml.php) according to the instructions within that same file, at line 137 :

 

        // to enable logging, create an empty "upsxml.log" file at the location you set below, give it write permissions (777) and uncomment the next line
        $this->logfile = '/srv/www/htdocs/catalog/includes/modules/shipping/upsxml.log';
        // to enable logging of just the errors, do as above but call the file upsxml_error.log
        $this->ups_error_file = '/srv/www/htdocs/catalog/includes/modules/shipping/upsxml_error.log';
 

I did indeed comment out the two lines (as shown above), created a upsxml_error.log file (by copying upsxml.log file and renaming) and gave full write permissions to the files.

 

However, I do not see than anything at all has been written to either of those files.

 

This is a somewhat separate issue, as here I'm just trying to get logging and error logging to write, so that I can see whether there are any actual problems or not.  My original post #2438 above about error messages might well be due to customers (esp. those not registered in osC) not entering correct destinations -- can't know without the logs working.

Share this post


Link to post
Share on other sites

I have the 1.5.1 version installed, and it's pulling up correct rates in the return XML which I can see in the log file. I'm not getting rates / options to select to show up on the checkout_shipping.php page however. By all accounts it looks like the module is running and working, just not showing up as a selection for the shipping method selection.

 

I'm running v2.3.4BS GOLD so I'm not certain if that would have anything to do with it or not... but I've been racking my brain on this one for a few days and have to admit I'm somewhat baffled as to why it's not working completely to the UI.

 

OB debugging checks:

  • Yes, the module is enabled, thus the correctly formatted XML query in the log
  • Yes, all my ups creds are correct, thus the correctly formatted XML response in the log
  • Yes, the shipping method option sort and display options are enabled (from a SPPC interaction)
  • My other two shipping methods are showing up and working correctly, it's just the UPSXML shipping module results which aren't showing up (see attached screenshot)
  • I've tried using the example_response.xml file also, just to see if there might be something with the returned XML that's causing my problems, no joy there either. Still not getting a result to the user selection in checkout_shipping.php

Any insights into how to further debug or what could possibly be wrong here as to why I'm getting good rates back but it's not making it to the checkout_shipping.php selections would be greatly appreciated!

post-341041-0-84060100-1485721984_thumb.jpg

Edited by mattsc

Share this post


Link to post
Share on other sites

I have the 1.5.1 version installed, and it's pulling up correct rates in the return XML which I can see in the log file. I'm not getting rates / options to select to show up on the checkout_shipping.php page however. By all accounts it looks like the module is running and working, just not showing up as a selection for the shipping method selection.

 

Anyone??? This remaining issue is the final part of taking my store live. I'm getting valid XML back with a number of shipping quotes. The selections just aren't making it to the UI. I'm totally at a loss as to how to further figure out what's wrong. I've poured through the code and am apparently just being daft or something.

Share this post


Link to post
Share on other sites

I just installed a fresh copy of the Edge release, then added the Compatibility Addon and the UPSXML Addon (Version 1.5.1). I did get it working, but I had to patch the XML class file to stop PHP from complaining. You may not have this problem depending on your error reporting settings -- mine are set to Strict and to report all errors, since I use this box for debugging.

 

@@mattsc: Do you see any errors in your PHP error log? Did you make the changes to the admin/modules.php per the UPSXML installation instructions? Did you use the Compatibility Addon or did you patch manually?

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

@@kymation: To answer your first question, yes I patched the admin/modules.php. I don't have the compatibility addon installed. Not sure what that is. I'm running Gold not Edge, so that may be related to that. From what I can tell at this point with further debugging, which is basically me stepping through the whole chain of function calls, I seem to be having a problem with the XML Class. The call into XML_unserialize is returning an empty array (verified with print_r and var_dump). Debugging into the xml.php in the XML_unserialize function, the call into $xml_parser->parse($xml) returns empty. 

 

The problem from what I can tell is coming up here:

        function parse($data){
                $this->document = array();
                $this->stack    = array();
                $this->parent   = $this->document;
                return xml_parse($this->parser, $data, true) ? $this->document : NULL;
        }

The function is fed in good XML which is what I've gotten back from UPS. This data is the XML stream received from the call to UPS, or by using the dummy xml test file, both call into _parseResult($xmlResult), which then calls XML_unserialize, and that's where the wheels come off. $xmlResult is valid, but XML_unserialize returns with the empty array.

 

I did strip the & reference chars from the class due to the fatal "Call-time pass-by-reference has been removed" errors. Maybe I stripped one too many. Ah HAAAAA!

 

Looks like that was the issue. I got over eager on my nuking of & characters. I'm getting quotes back now, finally! I've got a currency conversion issue to deal with, but THAT I can sort out.

Share this post


Link to post
Share on other sites

I also had problems with the XML class, and I also had to remove a couple of pass-by-reference "&" characters. Apparently I got the right ones. I'm glad you got this figured out.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

My problem is the error: Couldn't find constant UPSXML_--none-- in....

 

However, I did attempt to get the code changed in modules.php as the install directions say, but it was slightly different. I had installed the USPS rates module so the code differed slightly. Here is my present code block:

  if (tep_not_null($action)) {
    switch ($action) {
      case 'save':
        reset($HTTP_POST_VARS['configuration']);
        while (list($key, $value) = each($HTTP_POST_VARS['configuration'])) {
          // USPS START
          if (is_array($value))
            $value = implode(', ', $value);
          // USPS END
          tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $value . "' where configuration_key = '" . $key . "'");
        }
 

If I change the code to include the extra line...

  if (tep_not_null($action)) {
    switch ($action) {
      case 'save':
        reset($HTTP_POST_VARS['configuration']);
        while (list($key, $value) = each($HTTP_POST_VARS['configuration'])) {
          // USPS START
          if (is_array($value))
            $value = implode(', ', $value);
                        $value = preg_replace ("/, --none--/", "", $value);
                      }

          // USPS END
          tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $value . "' where configuration_key = '" . $key . "'");
        }
        tep_redirect(tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $HTTP_GET_VARS['module']));
        break;

I get this error: Parse error: syntax error, unexpected 'case' (T_CASE) in....

 

So I am thinking it broke the {  } syntax. So I added a {

  if (tep_not_null($action)) {
    switch ($action) {
      case 'save':
        reset($HTTP_POST_VARS['configuration']);
        while (list($key, $value) = each($HTTP_POST_VARS['configuration'])) {
          // USPS START
          if (is_array($value)){
            $value = implode(', ', $value);
                        $value = preg_replace ("/, --none--/", "", $value);
                      }

          // USPS END
          tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $value . "' where configuration_key = '" . $key . "'");
        }

So, I then I get back to Couldn't find constant UPSXML_--none-- in....

 

So nothing seems to work for me. Anyone have any suggestions?

 

 

Mark


Community Bootstrap Edition, Edge

 

Avoid the most asked question. See How to Secure My Site and How do I...?

Share this post


Link to post
Share on other sites

Your fix is correct. The error you are getting is there because you installed the module without having this change in place, and that put an invalid entry into your database. Uninstall the module to remove the invalid entry and install again.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

Thanks, that was it.

 

Now something new. I get the error Call-time pass-by-reference has been removed in....

 

Which, I know the reasons, but when xml.php tests for the version of php using

if (PHP_VERSION >= '5.0.0')

PHP_VERSION returns a null value and therefore executes the code as if it is the older version of php.

 

PHP_VERSION is set by environment variables by php, right? Rather than change all the code, or erase the inapplicable code and force the new code, where can I check for php not setting the value of PHP_VERSION?

 

My Server info in Administration properly shows a current version of php.

 

 

Mark


Community Bootstrap Edition, Edge

 

Avoid the most asked question. See How to Secure My Site and How do I...?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×