Magento Forum

Page 1 of 3
Fix for UPS XML “Unavailable” Error
 
CreedFeed
Member
 
Total Posts:  74
Joined:  2007-08-31
Milwaukee, WI
 

Edit >> Note, I am using Magento ver. 1.0.19870.4

I was attempting to configure the UPS XML Shipping Method today and kept getting the following error message when trying to obtain a quote:

This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.

I did some searching and found other people were having problems with the UPS XML Shipping Method. I found this thread which contains a bunch of information for updating the settings in the admin panel as well as a few changes to the core code to update the way the CURL request was made. I tried all of these methods and still received the same error.

I did a bit more investigating and found that I was actually receiving data from UPS. Assuming you have not made any changes to the core files, the following file deals with the UPS XML Shipping:

app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php

In this file on line 570 the CURL request is made and the response back is stored in $xmlResponse

$xmlResponse curl_exec ($ch);

On the next line I added a var_dump to see what response I was receiving, and I was in fact receiving a valid response with shipping prices!

$xmlResponse curl_exec ($ch);
var_dump($xmlResponse); die;

This led me to further investigate and I found what appears to be a bug in the code. The error was occuring in the function _parseXmlResponse. Again, assuming you have not touched this file, the following code block is the problem. It starts at line 581:

581        if (strlen(trim($xmlResponse))>0{
582            $xml 
= new Varien_Simplexml_Config();
583            $xml->loadString($xmlResponse);
584            $arr $xml->getXpath("//RatingServiceSelectionResponse/Response/ResponseStatusCode/text()");
585            $success = (int)$arr[0][0];
586            $result Mage::getModel('shipping/rate_result');
587            if($success===1){
588                $arr 
$xml->getXpath("//RatingServiceSelectionResponse/RatedShipment");
589                $allowedMethods explode(","$this->getConfigData('allowed_methods'));
590                foreach ($arr as $shipElement){
591                    $code 
= (string)$shipElement->Service->Code;
592                    #$shipment = $this->getShipmentByCode($code);
593                    if (in_array($code$allowedMethods)) {
594                        $costArr[$code] 
$shipElement->TotalCharges->MonetaryValue;
595                        $priceArr[$code] $this->getMethodPrice(floatval($shipElement->TotalCharges->MonetaryValue),$code);
596                    }
597                }
598            } 
else {
599                $arr 
$xml->getXpath("//RatingServiceSelectionResponse/Response/Error/ErrorDescription/text()");
600                $errorTitle = (string)$arr[0][0];
601                $error Mage::getModel('shipping/rate_result_error');
602                $error->setCarrier('ups');
603                $error->setCarrierTitle($this->getConfigData('title'));
604                //$error->setErrorMessage($errorTitle);
605                $error->setErrorMessage($this->getConfigData('specificerrmsg'));
606            }
607        }

On line 584 we grab the ResponseStatusCode from the response we get back from UPS. If it was successful, that tag should be set to the value “1”. What we actually get back here (assigned to the variable $arr) is an array of data. On line 585 we extract the specific value we need from that array and store it in the variable $success. This is where the bug is. Line 585 is assuming that the array $arr is an array holding an array so $arr[0][0] would be the value we need. This is wrong though. There is actually an object being stored in $arr[0] of the type Varien_Simplexml_Element. Thus the code needs to be modified to grab the value from this object. The modification I made is as follows:

$arr $xml->getXpath("//RatingServiceSelectionResponse/Response/ResponseStatusCode/text()");
            
$tmp $arr[0]->asArray();
            
$success = (int)$tmp[0];
            ....

Making this change appears to have solved the problem as the proper shipping quotes are displaying in the shopping cart page.

 
Magento Community Magento Community
Magento Community
Magento Community
 
nester
Jr. Member
 
Total Posts:  7
Joined:  2008-06-11
 

You are a genius.

Thank you!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Pukos
Sr. Member
 
Avatar
Total Posts:  108
Joined:  2008-02-15
 

I love you!

But (for me) it works only if i choose “Regular daily pickup”.
Is the same for you?

 
Magento Community Magento Community
Magento Community
Magento Community
 
CreedFeed
Member
 
Total Posts:  74
Joined:  2007-08-31
Milwaukee, WI
 
Pukos - 02 July 2008 07:10 AM

I love you!

But (for me) it works only if i choose “Regular daily pickup”.
Is the same for you?

Nope, all of the different Pickup Methods work for me. I get different quotes for each pickup type.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Pukos
Sr. Member
 
Avatar
Total Posts:  108
Joined:  2008-02-15
 

I receive this error: string(478) “Rating and Service1.00FailureHard111370Unsupported Pickup Type”

Seem a problem with the API, but WHY it happen only to me?! :(

Any idea?

Tnx

 
Magento Community Magento Community
Magento Community
Magento Community
 
CreedFeed
Member
 
Total Posts:  74
Joined:  2007-08-31
Milwaukee, WI
 

What pickup type did you use to get that error? And is your account set up to support that type?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Pukos
Sr. Member
 
Avatar
Total Posts:  108
Joined:  2008-02-15
 

I receive this error with every pickup type other than “Regular daily pickup” but i don’t know how to check pickup type my account support.
I’m gona try to call the UPS support and ask them....

 
Magento Community Magento Community
Magento Community
Magento Community
 
Pukos
Sr. Member
 
Avatar
Total Posts:  108
Joined:  2008-02-15
 

Anyway I’m using an UPS Shipping XML Key for sure.
But i can’t find any option regarding the pickup methods or limitations.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Pukos
Sr. Member
 
Avatar
Total Posts:  108
Joined:  2008-02-15
 

Finally solved the quest, UPS replyed me: “Daily Pickup is the only pickup type allowed for Non-US/PR/CA origins”

 
Magento Community Magento Community
Magento Community
Magento Community
 
infield
Sr. Member
 
Total Posts:  89
Joined:  2007-11-04
San Francisco
 

Has this been resolved in 1.1.1?

 
Magento Community Magento Community
Magento Community
Magento Community
 
infield
Sr. Member
 
Total Posts:  89
Joined:  2007-11-04
San Francisco
 

1.1.2 solved all my problems. smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
jmlee
Member
 
Total Posts:  53
Joined:  2008-06-23
 

When I add the line: var_dump($xmlResponse); die;

after

$xmlResponse = curl_exec ($ch);

I get a: “bool(false)”

does that even mean it has communicated with UPS XML service?

I am confused about this. If anybody can help, i’d greatly appreciate it.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Webunity
Member
 
Total Posts:  55
Joined:  2008-06-17
 

Please note, in order to fix the UPS tracking, you also have to change the “success” part in the function “_parseXmlTrackingResponse”

so it reads:

...
            
$arr $xml->getXpath("//TrackResponse/Response/ResponseStatusCode/text()");
            
$tmp $arr[0]->asArray();
            
$success = (int)$tmp[0];
            if(
$success===1){
...
 
Magento Community Magento Community
Magento Community
Magento Community
 
leetaylordoes
Sr. Member
 
Total Posts:  227
Joined:  2008-02-05
San Diego, CA
 

Hi All,

Has anyone any more problems with this?

I’d be happy to try and assist you in getting this up and going.

The list of replies on this forum is lengthy, and a Wiki might be a good idea to discuss the necessary steps in enabling the following:
- UPS XML General rates
- UPS XML Negotiated rates

I can get one up if all believe it to be beneficial.

Thanks,
Lee

 
Magento Community Magento Community
Magento Community
Magento Community
 
Pukos
Sr. Member
 
Avatar
Total Posts:  108
Joined:  2008-02-15
 

I’m having still some problem with the UPS XML Negotiated rates but everything seems correct :(

I had sent the xml generated to UPS to check if the problem is my or theirs…

 
Magento Community Magento Community
Magento Community
Magento Community
 
leetaylordoes
Sr. Member
 
Total Posts:  227
Joined:  2008-02-05
San Diego, CA
 

Hi @Pukos,

In which way have you modified the Magento code? Did you simply modify the Ups.php file or did you get a chance to create a new module?

Also, are you able to throw in a “var_dump($xmlRequest); var_dump($xmlResponse);” in near line 675 or so to display any errors?

I have successfully implemented negotiated rates on one of our client’s sites.

Thanks,
Lee

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 3