Jump to content
torinwalker

New UPS XML Shipping Module available

Recommended Posts

...can anybody offer an easy fix for the "Fatal error: Call to a member function on a non-object " error yet(refer to above post)? It would be mucho appreciated ;)

Share this post


Link to post
Share on other sites

Unfortunately.... I have made all test as posible and it does not work if shows transit time. Checkout_shipping reload again for ever.

 

I hope a new patch.

 

Than you very much anyway for your help.

Share this post


Link to post
Share on other sites

Paco,

 

Thanks for pointing out the error. I had the same problem on the live server and didn't know it yet....

 

I fixed it luckily. Find somewhere around line 228:

                // BOF limit choices
               if (!exclude_choices($type)) continue;
               // EOF limit choices
               if ( $method == '' || $method == $type ) {
   
  	 if (isset($this->servicesTimeintransit[$type])) {
  	 $type .= ", ".$this->servicesTimeintransit[$type]["date"];
   }
   
                   $methods[] = array('id' => $type, 'title' => $type, 'cost' => ($this->handling_fee + $cost));
               }

It goes wrong because the 'title' is changed with adding the date. A simple change will fix that:

                // BOF limit choices
               if (!exclude_choices($type)) continue;
               // EOF limit choices
               if ( $method == '' || $method == $type ) {
   
  	 if (isset($this->servicesTimeintransit[$type])) {
  	 $_type = $type . ", ".$this->servicesTimeintransit[$type]["date"];
   }
   
                   $methods[] = array('id' => $type, 'title' => $_type, 'cost' => ($this->handling_fee + $cost));
               }

Share this post


Link to post
Share on other sites

Paco, I understand that you got upsxml working now. Great to hear.

 

To avoid further grieve I updated the contribution here and there to include the fixes (version 1.1.2). Hopefully this will give new users less headache. ;)

Share this post


Link to post
Share on other sites
To avoid further grieve I updated the contribution here and there to include the fixes (version 1.1.2). Hopefully this will give new users less headache. ;)

 

does that include a fix for the issue I previously came across?

 

...starting to feel invisible, I asked about this a couple times lately with no reply. Last time I checked on here everybody started having this same problem and people were working on it. :blink:

Share this post


Link to post
Share on other sites
does that include a fix for the issue I previously came across?

 

...starting to feel invisible, I asked about this a couple times lately with no reply.

I really wouldn't know. Personally, I haven't seen that error ever on four different setups (two Linux servers, two MacOSX computers). If I could replicate the error I could take a look at it, but alas.

 

I think the last version does include some nice improvements to the code that Stuart Owens and Greg MacLellan have added, so I would say it is worthwhile to install this version (I introduced a logic error, but have corrected that in the "new" 1.1.3 version.

 

Depending on the version that you use now, you might have to add a few functions (see README.TXT), change a MySQL table from var(255) to text and replace a few files (includes/modules/shipping/upsxml.php, includes/languages/english/modules/shipping/upsxml.php for sure and admin/packaging.php likely) before you "remove" the UPSXML module in the admin section and then "install" again.

Share this post


Link to post
Share on other sites

I think I may have found an issue with the contribution :-0

 

I have it installed with dimensions and working fine with the help of Stuart. However, I did find something interesting.....

 

I have 4 test products installed complete with dimensions and weight etc. When I go to checkout it does not show the correct total weight and also does not send the correct weight to UPS for the quotes.

 

For instance, adding a certain 4 items to my cart means a total weight of 27.22 Kilograms. Each weight is defined properly for each product in the admin. When I go to check out the displayed total weight is 9.95 kg's!! As a result the shipping estimate is off by several hundred dollars.

 

It does disply that it needs 4 boxes for the 4 items - just for some reason is not displaying the proper total weight. To give you an idea as to how far it's out....

 

From Canada (my store) to Taiwan using 27.22 kilos spread over 4 boxes means UPS shipping rates of;

 

283.49 or

240.98

 

Whereas the proper Canada Post calculation is;

 

679.61 or

465.30 or

244.64

 

Has anyone noticed this problem?


Best & Thanks;
Marvin
----------------------
osCommerce 2.3.3.4 

Share this post


Link to post
Share on other sites

Pardon me, the data being sent to UPS includes the proper weight for one item and then for the rest of the items it seems to send the weight figures as 1 !!

 

<?xml version="1.0"?>
<RatingServiceSelectionRequest xml:lang="en-US">
  <Request>
      <TransactionReference>
          <CustomerContext>Rating and Service</CustomerContext>
          <XpciVersion>1.0001</XpciVersion>
      </TransactionReference>
      <RequestAction>Rate</RequestAction>
      <RequestOption>shop</RequestOption>
  </Request>
  <PickupType>
      <Code>01</Code>
  </PickupType>
  <Shipment>
      <Shipper>
          <Address>
              <City>Parksville</City>
              <StateProvinceCode>BC</StateProvinceCode>
              <CountryCode>CA</CountryCode>
              <PostalCode>V9P1B4</PostalCode>
          </Address>
      </Shipper>
      <ShipTo>
          <Address>
              <City>Taipei</City>
              <StateProvinceCode>N/A</StateProvinceCode>
              <CountryCode>TW</CountryCode>
              <PostalCode>N/A/N</PostalCode>
          </Address>
      </ShipTo>
      <Package>
          <PackagingType>
              <Code>02</Code>
          </PackagingType>
          <Dimensions>
              <UnitOfMeasurement>
                  <Code>CM</Code>
              </UnitOfMeasurement>
              <Length>40.00</Length>
              <Width>22.00</Width>
              <Height>9.00</Height>
          </Dimensions>
          <PackageWeight>
              <UnitOfMeasurement>
                  <Code>KGS</Code>
              </UnitOfMeasurement>
              <Weight>1</Weight>
          </PackageWeight>
      </Package>
      <Package>
          <PackagingType>
              <Code>02</Code>
          </PackagingType>
          <Dimensions>
              <UnitOfMeasurement>
                  <Code>CM</Code>
              </UnitOfMeasurement>
              <Length>40.00</Length>
              <Width>22.00</Width>
              <Height>9.00</Height>
          </Dimensions>
          <PackageWeight>
              <UnitOfMeasurement>
                  <Code>KGS</Code>
              </UnitOfMeasurement>
              <Weight>1</Weight>
          </PackageWeight>
      </Package>
      <Package>
          <PackagingType>
              <Code>02</Code>
          </PackagingType>
          <Dimensions>
              <UnitOfMeasurement>
                  <Code>CM</Code>
              </UnitOfMeasurement>
              <Length>40.00</Length>
              <Width>22.00</Width>
              <Height>9.00</Height>
          </Dimensions>
          <PackageWeight>
              <UnitOfMeasurement>
                  <Code>KGS</Code>
              </UnitOfMeasurement>
              <Weight>1</Weight>
          </PackageWeight>
      </Package>
      <Package>
          <PackagingType>
              <Code>02</Code>
          </PackagingType>
          <Dimensions>
              <UnitOfMeasurement>
                  <Code>CM</Code>
              </UnitOfMeasurement>
              <Length>45.00</Length>
              <Width>26.00</Width>
              <Height>30.00</Height>
          </Dimensions>
          <PackageWeight>
              <UnitOfMeasurement>
                  <Code>KGS</Code>
              </UnitOfMeasurement>
              <Weight>9.2</Weight>
          </PackageWeight>
      </Package>
  </Shipment>


Best & Thanks;
Marvin
----------------------
osCommerce 2.3.3.4 

Share this post


Link to post
Share on other sites

Jesse,

 

You mean that sometimes you get good quotes and sometimes you get the error? I looked at the code and in my opinion, if there is no response from the UPS server you should get the error message: "An unknown error occured while attempting to contact the UPS gateway".

 

This would mean it is something on the UPS side, not the osC side. It would have taken more than 60 seconds for the UPS server to respond, because the timeout is set to 60 seconds.

Share this post


Link to post
Share on other sites

Marvin,

 

This is not OK of course. I don't have DIMENSIONS SUPPORTED so I can't check what goes wrong. I looked at the code to see if there is some obvious error, but I can't see it.

 

The strange thing is that in the same piece of code (starting around line 196) that is adding the box dimensions and weights to the shipping list, the weights are added together to get the total weight. And the total weight is correct :huh:

           for ($i = 0; $i < count($boxesToShip); $i++) {
               $this->_addItem($boxesToShip[$i]['length'], $boxesToShip[$i]['width'], $boxesToShip[$i]['height'], $boxesToShip[$i]['current_weight']);
               $totalWeight += $boxesToShip[$i]['current_weight'];
           }

In the function _addItem I did see something that I haven't seen before, a cast to a float (see around line 356:

    function _addItem($length, $width, $height, $weight) {
       // Add box or item to shipment list. Round weights to 1 decimal places.
       if ((float)$weight < 1.0) {
           $weight = 1;
       } else {
           $weight = round($weight, 1);
       }
       $index = $this->items_qty;
       $this->item_length[$index] = ($length ? (string)$length : '0' );
       $this->item_width[$index] = ($width ? (string)$width : '0' );
       $this->item_height[$index] = ($height ? (string)$height : '0' );
       $this->item_weight[$index] = ($weight ? (string)$weight : '0' );
       $this->items_qty++;
   }

If the weight of the box with product is below 1.0 LBS or KGS (whatever your weight unit is) the line if ((float)weight < 1.0 should set the weight to 1. According to www.php.net float was introduced with PHP 4.2.0 and is the recommended one. The old one is "double" instead of float. You might try that, but I don't have high hopes this will be the solution.

Share this post


Link to post
Share on other sites

Hi Jan;

 

Thanks for the tips. I'm going to try to look into it further but my PHP skills are quite limited. I did try something else though to narrow it down - I turned off dimensions support by changing the

define('DIMENSIONS_SUPPORTED', 1);

line to 0. This turns off dimensional support and I then re-tried the checkout process.

 

It then correctly calculated the total weight of all items so at least we can narrow down the issue to the dimensions section of the code.

 

Hopefully someone familiar with PHP and the dimensions side of this contribution will post up their findings. Are you having the same problem? I strongly suspect this is an actual contribution error as opposed to an installation error :D


Best & Thanks;
Marvin
----------------------
osCommerce 2.3.3.4 

Share this post


Link to post
Share on other sites
Jesse,

 

You mean that sometimes you get good quotes and sometimes you get the error? I looked at the code and in my opinion, if there is no response from the UPS server you should get the error message: "An unknown error occured while attempting to contact the UPS gateway".

 

This would mean it is something on the UPS side, not the osC side. It would have taken more than 60 seconds for the UPS server to respond, because the timeout is set to 60 seconds.

 

 

Well I am not sure what happened but it doesnt work at all now and I reverted to a working backup (DB and files) still get the same error. Running the current version of curl and apache 2. It doesn't even seem like it's hitting UPS. It comes up immediately saying the rating and service gateway error. Uhggg... I have 3 shops I FULLY customized and just got working perfectly for release next week and then this happens. :( I am about to give up. the creator of this module should look into this more. It's a VERY useful module!

Share this post


Link to post
Share on other sites

Could someone look into curl a bit further? Maybe the ratings and services error has something to do with that.

 

libcurl/7.12.0 zlib/1.1.4

 

Apache 2

 

Mod version: 1.1.3

 

and its not working.

Share this post


Link to post
Share on other sites

Sorry to post so many times in a row, but I have to spend every hour of every work day on this til it's fixed. :(

 

So I turned on the UPS module (not the XML one discussed here) and it contacts UPS no problem and come back with prices. Obviously the prices are wrong, but the fact that it does come back with prices shows me the Rating and Services gateway error is NOT on UPS' end or an issue with curl I believe. It's an actual problem with the script itself.

Share this post


Link to post
Share on other sites
Sorry to post so many times in a row, but I have to spend every hour of every work day on this til it's fixed. :(

 

So I turned on the UPS module (not the XML one discussed here) and it contacts UPS no problem and come back with prices. Obviously the prices are wrong, but the fact that it does come back with prices shows me the Rating and Services gateway error is NOT on UPS' end or an issue with curl I believe. It's an actual problem with the script itself.

 

I realize one is cgi and one is XML.

Share this post


Link to post
Share on other sites

Everything looks fine to me... why does that stupid error keep coming up.

 

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

 

------------------------------------------

UPS URL: https://wwwcie.ups.com:443/ups.app/xml/TimeInTransit

UPS REQUEST: <?xml version="1.0"?>

<AccessRequest xml:lang="en-US">

<AccessLicenseNumber>####</AccessLicenseNumber>

<UserId>####</UserId>

<Password>####</Password>

</AccessRequest>

<?xml version="1.0"?>

<TimeInTransitRequest xml:lang="en-US">

<Request>

<TransactionReference>

<CustomerContext>Time in Transit</CustomerContext>

<XpciVersion>1.0001</XpciVersion>

</TransactionReference>

<RequestAction>TimeInTransit</RequestAction>

</Request>

<TransitFrom>

<AddressArtifactFormat>

<PoliticalDivision2>Chatsworth</PoliticalDivision2>

<PoliticalDivision1>CA</PoliticalDivision1>

<CountryCode>US</CountryCode>

<PostcodePrimaryLow>91311</PostcodePrimaryLow>

</AddressArtifactFormat>

</TransitFrom>

<TransitTo>

<AddressArtifactFormat>

<PoliticalDivision2>Sherman Oaks</PoliticalDivision2>

<PoliticalDivision1>CA</PoliticalDivision1>

<CountryCode>US</CountryCode>

<PostcodePrimaryLow>91423</PostcodePrimaryLow>

<PostcodePrimaryHigh>91423</PostcodePrimaryHigh>

</AddressArtifactFormat>

</TransitTo>

<PickupDate>20041130</PickupDate>

<ShipmentWeight>

<UnitOfMeasurement>

<Code>LBS</Code>

</UnitOfMeasurement>

<Weight>10</Weight>

</ShipmentWeight>

<InvoiceLineTotal>

<CurrencyCode>USD</CurrencyCode>

<MonetaryValue>100</MonetaryValue>

</InvoiceLineTotal>

</TimeInTransitRequest>

 

UPS RESPONSE:

------------------------------------------

Time in Transit: 0

------------------------------------------

UPS URL: https://wwwcie.ups.com:443/ups.app/xml/Rate

UPS REQUEST: <?xml version="1.0"?>

<AccessRequest xml:lang="en-US">

<AccessLicenseNumber>####</AccessLicenseNumber>

<UserId>####</UserId>

<Password>####</Password>

</AccessRequest>

<?xml version="1.0"?>

<RatingServiceSelectionRequest xml:lang="en-US">

<Request>

<TransactionReference>

<CustomerContext>Rating and Service</CustomerContext>

<XpciVersion>1.0001</XpciVersion>

</TransactionReference>

<RequestAction>Rate</RequestAction>

<RequestOption>shop</RequestOption>

</Request>

<PickupType>

<Code>01</Code>

</PickupType>

<Shipment>

<Shipper>

<Address>

<City>Chatsworth</City>

<StateProvinceCode>CA</StateProvinceCode>

<CountryCode>US</CountryCode>

<PostalCode>91311</PostalCode>

</Address>

</Shipper>

<ShipTo>

<Address>

<City>Sherman Oaks</City>

<StateProvinceCode>CA</StateProvinceCode>

<CountryCode>US</CountryCode>

<PostalCode>91423</PostalCode>

</Address>

</ShipTo>

<Package>

<PackagingType>

<Code>02</Code>

</PackagingType>

<PackageWeight>

<UnitOfMeasurement>

<Code>LBS</Code>

</UnitOfMeasurement>

<Weight>92</Weight>

</PackageWeight>

</Package>

<Package>

<PackagingType>

<Code>02</Code>

</PackagingType>

<PackageWeight>

<UnitOfMeasurement>

<Code>LBS</Code>

</UnitOfMeasurement>

<Weight>92</Weight>

</PackageWeight>

</Package>

</Shipment>

<CustomerClassification>

<Code>01</Code>

</CustomerClassification>

</RatingServiceSelectionRequest>

 

UPS RESPONSE:

Edited by eTron

Share this post


Link to post
Share on other sites

Jesse,

 

I have nill zero nada experience with cURL, but since it comes up immediately you must be right that there is a problem with cURL on your server. I found an example in PHP Developer's Cookbook that prints out cURL errors. That might come in handy.

 

Why don't you try changing (around line 600):

        $ch = curl_init();
       curl_setopt($ch, CURLOPT_URL, $url);

to:

        $ch = curl_init($url);
if (!$ch) {
   die(sprintf('Error [%d]: %s',
   curl_errno($ch), curl_error($ch)));
}
//        curl_setopt($ch, CURLOPT_URL, $url);

Perhaps it will give some useful info?

Share this post


Link to post
Share on other sites

I installed ZenCart fresh (even though its based off oscommerce) and installed the modified version of this module and it produces the same error. I'm wondering if it's something on my hosts end. What could cause this. Version of curl, XML not installed right, ?????

 

I'm dyin here trying to figure this out. My fiance is about to shank me if I don't get up.

Share this post


Link to post
Share on other sites
Jesse,

 

I have nill zero nada experience with cURL, but since it comes up immediately you must be right that there is a problem with cURL on your server. I found an example? in PHP Developer's Cookbook that prints out cURL errors. That might come in handy.

 

Why don't you try changing (around line 600):

 ? ? ? ?$ch = curl_init();
? ? ? ?curl_setopt($ch, CURLOPT_URL, $url);

to:

 ? ? ? ?$ch = curl_init($url);
if (!$ch) {
? ?die(sprintf('Error [%d]: %s',
? ?curl_errno($ch), curl_error($ch)));
}
// ? ? ? ?curl_setopt($ch, CURLOPT_URL, $url);

Perhaps it will give some useful info?

 

 

HOLY F***ING SH*T!! It works!! OMG! THANK YOU!!

 

Only issue I see now is the prices are wrong, but it's getting there. If you have any idea why I'd be seeing the wrong prices let me know. :)

Edited by eTron

Share this post


Link to post
Share on other sites
HOLY F***ING SH*T!! It works!! OMG! THANK YOU!!

 

Only issue I see now is the prices are wrong, but it's getting there. If you have any idea why I'd be seeing the wrong prices let me know. :)

 

 

SCRATCH THAT!! IT ALL WORKS!! OMG!! YOU HAVE NO IDEA HOW THANKFUL I AM!! THANK YOU THANK YOU THANK YOU!! I created 3 carts that all of a sudden started having problems. This fixed them all just before I was about to go live.

Share this post


Link to post
Share on other sites

CRAP!! Scratch that... my host sent me an email at the same time saying they fixed it. Some settings were wrong on the server. So I tried the other 2 carts I didnt modify yet and those work fine now too so umm ya. That might be a fix for others though. Thank you sooo much again!!

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

×