Jump to content
Latest News: (loading..)
torinwalker

New UPS XML Shipping Module available

Recommended Posts

Hello Torin!

Let me start by thanking you for this wonderful contribution! It was so incredibly well documented and I enjoyed reading your instructions and thoughts. It was perhaps the easiest contribution I have ever installed!

 

I am trying to utilize the shipping dimensions feature and it is working quite well. However, I just encountered a minor bug:

 

The store I developed sells motorcycle tires. I configured them to be sent out in three different packages. 1 tire, 2 tires, and 3 tires.

 

The dimension of one tire is 27x8x27 (HxWxL)

 

Therefore I have configured packages (bundles) as following:

 

package 3 (for three tires to be shipped out) :dimensions 27x24x27

 

Now, everything works fine until I add the 4th tire to my shopping cart. Then for some weird reason the shopping cart doesn't add the 4th tire into a new package???

 

HOWEVER, when I add a 5th tire to the shopping cart the calculations know that an extra tire has been added and it therefore creates 2 packages to be sent by UPS (a bundle with 3 tires and an additional bundle with (it probably thinks 1 tire...although it should be 2 tires)).

 

One more reason why I can see that the addition is wrong is that the weight does not match the tires in line. For instance. (each tire weighs 10 lbs).

  • when 3 tires is added I get: 1package 31lbs (1lbs for empty package weight)

 

  • NOW, when 5 tires is added I get: 2 packages 41lbs

I continue to add tires and there is another tire lost when I have added 9 tires!!

 

The output is now:

 

 

Therefore, there has to be a minor error in the algorithm of yours. Because when I specify this same tire with the checkbox: Product can be shipped in its own container. I get the correct amount of packages: 9 packages and 90 lbs (the empty 3 lbs (1 per package) weight is lost since I don't use the dimesnions feauture this time...

 

DO YOU KNOW WHAT'S HAPPENING HERE?

 

Thanks, I will with the best of my ability check the code for bugs in this department...

Share this post


Link to post
Share on other sites

another minor bug I found...sorry I don't need to be a pain! I just want to point them out here for everyone to consider. I promise I will do my best to find the solution.

 

This one relates to the javascript row select background color (or how you would describe it)

 

The function is:

onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect

 

It works as it's supposed to if you have another than the UPS XML module activated. say and additional Fedex module.

 

However when a store owner only uses the UPS XML module the default of all the different UPS options is row background ON. i.e:

 

id="defaultSelected" class="moduleRowSelected"

 

Is there a way to have only the top UPS choice on with the default background when only the UPS XML module is active?

 

or would it be possible to have none default background color?

 

I guess this is mostly cosmetic however it might dissorient a user that tried to hit many of the UPS options and as he moves his mouse away some of them will turn back with no background....

 

Where is this function controlled anyhow? Is it in an osCommerce general javascript file?

Share this post


Link to post
Share on other sites

Gosh darn it!!

 

It seems like the javascript row select background problem I had above has more serious implications...

 

Because, right now only the very top (cheapest or ground) option let's you continue with the checkout process...

 

Anyone had the same problem?

 

When I choose a speedier shipping option the checkout_shipping.php page simply reloads.

 

I figured out that the javascript that chooses the control choice row is in the checkout_shipping file in the header. Additionally there is this php function (approx line 341):

 

<?php

       } else {

         for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) {

// set the radio button to be checked if it is the method chosen

           $checked = (($quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $shipping['id']) ? true : false);



           if ( ($quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $shipping['id']) || (tep_count_shipping_modules() == (int)1) ) {

             echo '                  <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "n";

           } else {

             echo '                  <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "n";

           }

?>

 

When I changed this:

 

(tep_count_shipping_modules() == (int)1)

 

to this

 

(tep_count_shipping_modules() == (int)0)

 

I was able to get rid of the entire background color. But it doesn't matter if it is a 1 or a 0...The result is still the same. No continuation in the checkout process if you choose a shipping option other than the top (ground or cheapest) one.

 

Got any ideas? I'm exhausted and going to get some rest...

Share this post


Link to post
Share on other sites
When I choose a speedier shipping option the checkout_shipping.php page simply reloads.

 

Yes, I am having this problem too and the shipping quote doubles when the page is reloaded. I failed to test these expediated services before I read your post. :oops: I guess I better swing back to the old module until this is sorted out. Is there a way to disable the expediated services until this is resolved?

Millie

Share this post


Link to post
Share on other sites

I dunno why, but i have no selection for Residential/Commercial Delivery in Admin.

The Module works realy good so far but i always get Rates for Commercial Delivery. I took a look into the database table configuration

and changed the configuration_key to Residential but still didn't get the Residential Delivery.

 

configuration_id configuration_title configuration_key configuration_value configuration_description configuration_group_id sort_order last_modified date_added use_function set_function

1439 Quote Type MODULE_SHIPPING_UPSXML_RATES_QUOTE_TYPE Residential Quote for Residential or Commercial Delivery 6 9 17.07.2003 20:37:21 tep_cfg_select_option(array('Commercial', 'Residential'),

 

What else could be wrong?

Origin is Potsdam/Germany

 

Stephan


 

 

Share this post


Link to post
Share on other sites

Millie: I am almost sorry to hear you have the same problem! I thought maybe it was just me... I notified Torin about this per e-mail. Hopefully we will hear back sometime soon.

 

What do you mean by:

disable the expediated services

 

Do you mean the faster shipping options? (sorry English isn't my first language...I sometimes get terms I don't understand)

 

Stephan:Millie had a temporary solution:

 

I added  

 

Code:  

"<ResidentialAddressIndicator>1</ResidentialAddressIndicator>n".  

 

to the shipto area and I seem to be receiving accurate rates now!

 

This would be in in catalog/includes/modules/shipping/upsxml.php around line 520.

 

You can find Millie's post here:

 

http://forums.oscommerce.com/viewtopic.php...ps+xml&start=30

 

Unfortunately I think it makes every order handle like Residential ones. But the good news is that it seems Residential rates are slightly higher then Commercial...on so therefore you will at least not underrate your own business.

Share this post


Link to post
Share on other sites
What do you mean by:  

disable the expediated services  

 

Next Day, Second Day etc. I would prefer to disable the faster shipping services and just offer Ground using the XML module until the problem is resolved rather than revert to the older module.

Share this post


Link to post
Share on other sites

I have the same problem trying to get this working on MS2. Fortunately, I have not gone live yet. But I'm definitely going to get the XML based UPS rates working.

 

I figured out how to disable rates with very minor changes.

 

First, comment out all the rates you don't want starting at around line 116:

 

$this->service_codes = array(

// US Origin

'US Origin' => array(

// '01' => MODULE_SHIPPING_UPSXML_SERVICE_CODE_US_ORIGIN_01,

// '02' => MODULE_SHIPPING_UPSXML_SERVICE_CODE_US_ORIGIN_02,

'03' => MODULE_SHIPPING_UPSXML_SERVICE_CODE_US_ORIGIN_03,

// '07' => MODULE_SHIPPING_UPSXML_SERVICE_CODE_US_ORIGIN_07,

// '08' => MODULE_SHIPPING_UPSXML_SERVICE_CODE_US_ORIGIN_08,

// '11' => MODULE_SHIPPING_UPSXML_SERVICE_CODE_US_ORIGIN_11,

// '12' => MODULE_SHIPPING_UPSXML_SERVICE_CODE_US_ORIGIN_12,

// '13' => MODULE_SHIPPING_UPSXML_SERVICE_CODE_US_ORIGIN_13,

// '14' => MODULE_SHIPPING_UPSXML_SERVICE_CODE_US_ORIGIN_14,

// '54' => MODULE_SHIPPING_UPSXML_SERVICE_CODE_US_ORIGIN_54,

// '59' => MODULE_SHIPPING_UPSXML_SERVICE_CODE_US_ORIGIN_59,

// '65' => MODULE_SHIPPING_UPSXML_SERVICE_CODE_US_ORIGIN_65

),

 

 

Next, around line 650 look for:

 

for ($i = 0; $i < count($ratedShipments); $i++) {

$serviceCode = $ratedShipments[$i]->getValueByPath("/Service/Code");

$totalCharge = $ratedShipments[$i]->getValueByPath("/TotalCharges/MonetaryValue");

if (!($serviceCode && $totalCharge)) {

continue;

}

 

and place the following under the above line:

 

// Begin PVA Remove Service by commenting out in service code table

$title = $this->service_codes[$this->origin][$serviceCode];

if ( !isset($title) ) {

continue;

}

// End PVA Remove Service by commenting out in service code table

 

 

This should cause the module to return only the rates whos title is included in the constant array of titles.

Share this post


Link to post
Share on other sites

Everyone,

 

First of all, I'd like to express my appreciation for all the interest you've shown in the UPS XML module, and your willingness to explore the additional features I added to the regular shipping functions. I honestly didn't expect many of you to even bother with the dimensional support. Secondly, I'd like to thank those of you who have helped identify bugs and report them to me.

 

I will look at all the issues presented so far in the forum and attempt to address them all this weekend. At the moment, I'm in the middle of a design for my full-time job and it's eating into all my free time.

 

To answer some of your questions:

 

"I get a curl_init error..."

 

Sounds like curl needs to be enabled on your system. Go into admin->tools->server info page and take a look at the "Configure Command"

line. Look for the flag '--with-curl'. If you aren't the administrator of your own website, ask the hosting ISP whether they can enable CURL by either installing the necessary libraries, or adding the appropriate flag.

 

 

"Will it work in Germany"

"Does it handle the 'outside areas'"

"Does it handle dimensional weight (volume weight)?"

 

4. Does it handle additional services (e.g. insurance...)?

 

5. Is it implemented with the zones module or is it an entire separate modul?

 

 

Yes, it should work in Germany. Fill out the origin, and as much of the city, state, postal code and quotes should work fine. I haven't tested it with my location set to Germany, so if you encounter errors, finding them shouldn't be difficult.

 

It should handle any area that the UPS Rates and Services Gateway handles. I pass it as much information as is possible with the API, and it is up to UPS to declare whether it can handle the area or not.

 

I've never understood 'dimensional weight'. I am both a pilot, and a physics enthusiast, and I still don't get how L x W x H = m. The values passed to UPS correspond to the physical package dimensions and weight, and they are passed in the package dims/weight fields, not in the dimensional weight field.

 

Additional services are not implemented...yet. One of the additional services I would like to provide is Saturday delivery and Commercial/Residential quotes. This has been a sore point because it's not up to me (the storeowner) to determine whether it's a residential or commercial quote. To provide that option, I have to modify more of the osCommerce core functions, and I've already done enough damage. Additional services is one option that might be a ways down the road.

 

Finally, no, I'm sorry but the Zones feature, if it is another module, is not considered in this shipping module.

 

"Will it work with version 2.2 xxxxx"

 

I have not tested it on any other version except 2.2 MS1, but that does not mean it won't work. I've only been using osCommerce for a few weeks and have not seen it evolve to what it is today. By all means give it a try, but back up your site and try it with dimensions disabled first

 

Thomas, thanks for all that energy! I will definitely look into your dimensions bug and get back to you. The dimensions algorithm should work for such a simple set of parameters. Once we've cleared that up, I'll look into the HTML code problems.

 

 

Re: checkout_shipping.php reloading error.

 

I haven't made any changes that involve the checkout_shipping.php component, so I'm not sure if this is a related issue. I will keep an eye on it however while I'm doing my testing and see if I can't identify the problem.

 

 

Thanks everyone for all your help.

 

 

Torin...

Share this post


Link to post
Share on other sites

Stephan,

 

You're getting the same rate because the value isn't in the XML being sent to the gateway. This is one of the issues I will be addressing shortly.

 

 

Torin...

Share this post


Link to post
Share on other sites

Ok, I should not have posted my previous changes late at night, or without running a compare, or both.

 

In addition to the code I mentioned above, you need to make the following two changes to remove the extraneous entries from the array returned:

 

First, look for the following around line 650:

 

    for ($i = 0; $i < count($ratedShipments); $i++) {

 

Place the following line BEFORE the above line:

 

    $j = 0;  /* PVA Remove Services */

 

Second, look for the following line around line 676 (after making previous changes):

 

      $aryProducts[$i++] = array($title => $totalCharge);

 

And change it to:

 

      $aryProducts[$j++] = array($title => $totalCharge); /* PVA Remove Services */

 

The only difference in the second change is changing $i to $j.

Share this post


Link to post
Share on other sites

The updated UPS XML 1.02 module is available in the

<a href="http://www.oscommerce.com/community/contributions,1323">contributions</a> section.

 

This update fixes:

 

- Missing column in packages table

- Missing column in tep_query in admin/categories.php

- A bunch of updates to catalog/includes/modules/shipping/upsxml.php including Customer Classification and Res/Com quote types.

- Wrong service codes for the European Union

 

I added a new file, changes.txt, that will help with the differences between versions (makes it easier to update, rather than reinstall.)

 

As always, don't be shy... send me a message if you're encountering problems.

 

 

Torin...

Share this post


Link to post
Share on other sites

Stephan,

 

How very nice! Thank you very much for the offer, Stephan, but it was really nothing. Perhaps instead you could visit my still-not-completed-because-I'm-spending-so-much-time-on-other-things website and give me your opinion of the products I hope to offer this fall. Perhaps too you have a son around 10 - 12yrs who would enjoy one of my rather unique and very educational toys for Christmas. The website is:

 

www.geo-magnet.com

 

Visit the products section and have a look around.

 

Please excuse the mess. I'm between graphic designs, so some of the layouts and fonts are, ehm, discombobulated.

 

 

Torin...

Share this post


Link to post
Share on other sites

Seems to work fine now with Residential Deliviery. :D

But i have a Problem in my Shopping_Cart now.

I 'm using Ship_in_Cart Contribution to let the customer preview the Shipping Costs in his Shopping Cart.

It is showing the correct shipping costs but somehow i cannot select ups standard for example.

 

At the Checkout all is fine. There are no problems.

 

Maybe some1 else is using the Ship_in_Cart Contrib and maybe has the same problem as me :/

 

Later,

Stephan

 

watch the problem live at my demo-shop > www.mbeat.de/catalog/


 

 

Share this post


Link to post
Share on other sites

thank you for finally re-writing this beast

 

the install seemed to go fairly smoothly, but now i am testing and when i get to the shipping page i am receiving the following error:

 

Rating and Service 1.0001 0 MODULE_SHIPPING_UPSXML_RATES_TEXT_COMM_UNKNWON_ERROR : Rating and Service 1.0001 0 MODULE_SHIPPING_UPSXML_RATES_TEXT_COMM_UNKNWON_ERROR

 

I do have a valid access key


Reading is beneficial - Searching is enlightening

find answers at wiki.oscommerce.com/top

Share this post


Link to post
Share on other sites

Hello Torin,

Thanks so much for updating the contribution. I liked the added feautures in the admin panel. :D

 

Did you do anything with the size algorithm? And how about the possibility to continue checkout when choosing other options then "Ground" (or the top option)?

 

I updated the new files and I still have the same error with the algorithm and being able to checkout with other options then UPS Ground.

 

I noticed that the old UPS shipping module works as far as selecting any of the options. Maybe something to look into? How is that code arranging the different options?

 

I'm dead beat tired. I have to seriously focus on this tomorrow. Thanks!

Share this post


Link to post
Share on other sites

J,

 

Thanks for the update. I'm not sure why you're getting the error. I sometimes get the same error for no particular reason. I usually just retry it a few times, or wait a few minutes.

 

However, I will keep an open mind on this and will help you work it out if it continues to be a code problem.

 

I'm suprised I didn't notice this myself, but the error you're getting is due to a mistyped constant in the shipping module. If you look carefully at the message, you'll see a declared variable in all upper case. Look at the end, and you'll notice the UNKNOWN is actually mispelled UNKNWON. Sorry...too many late nights.

 

.

thank you for finally re-writing this beast

 

the install seemed to go fairly smoothly, but now i am testing and when i get to the shipping page i am receiving the following error:

 

Rating and Service 1.0001 0 MODULE_SHIPPING_UPSXML_RATES_TEXT_COMM_UNKNWON_ERROR :

 

Edit catalog/inclues/modules/shipping/upsxml.php, grep for UNKNWON and replace it with the properly spelled text. That should clean up the messy message.

 

 

Torin...

Share this post


Link to post
Share on other sites

J,

 

Thanks for the update. I'm not sure why you're getting the error. I sometimes get the same error for no particular reason. I usually just retry it a few times, or wait a few minutes.

 

Er, well, let me just clarify that a little further. I know why the error appears; The curl message being sent fails to retrieve a response (anything at all) from the UPS server. This is usally due to a timeout (busy), server down or being maintained, or a communications problem of some sort on the ISP or UPS end. What I don't know is why the communications errors occur. That's anyone's guess.

 

Perhaps the unknown comm error message could be better written,

 

"No response was received from the UPS Rates and Services gateway for your request. The service is most likely busy, or could be experiencing a communications problem. Please try again. If the problem persists, try again in a few minutes."

 

 

Torin...

Share this post


Link to post
Share on other sites

Mr. TF,

 

I am still getting to your report. I'll make up a few tires and try them out. I've been very busy, but I haven't forgotten about you.

 

 

Hello Torin,

Thanks so much for updating the contribution. I liked the added feautures in the admin panel. :D

 

Did you do anything with the size algorithm?

 

 

Torin...

Share this post


Link to post
Share on other sites

I just installed the latest update for the UPSXML contribution. First thank you for this module...it's nice to have a choice other than Canada Post.

 

I'm having some trouble with this mod, I've restored everything and reinstalled just in case. I'm at a total loss as to what I could have done wrong.. the install is so simple.

 

 

 

First, this store is located in Canada, using a Postal Code, not a zip code.

 

 

In the Admin section, clicking on Categories/Products, this error appears:

 

/ Fatal error: Call to undefined function: tep_array_merge() in /usr/local/psa/home/vhosts/prosport.ca/httpdocs/admin/categories.php on line 707

 

 

In the Tools box, this appears:

BOX_TOOLS_PACKAGING

 

 

 

In the Catalog, when checking out, the following appears in the Deliver Information (first screen when checking out):

 

United Parcel Service (XML)

Rating and Service 1.0001 0 MODULE_SHIPPING_UPSXML_RATES_TEXT_COMM_UNKNWON_ERROR : Rating and Service 1.0001 0 MODULE_SHIPPING_UPSXML_RATES_TEXT_COMM_UNKNWON_ERROR

 

 

thank you for any help you can give me...

Share this post


Link to post
Share on other sites

Hey Torin,

 

found this in upsxml.php module /catalog/includes/modules/shipping/

 

// European Union Origin

	 'European Union Origin' => array(

   '07' => MODULE_SHIPPING_UPSXML_SERVICE_CODE_EU_ORIGIN_07,

   '08' => MODULE_SHIPPING_UPSXML_SERVICE_CODE_EU_ORIGIN_08,

   '11' => MODULE_SHIPPING_UPSXML_SERVICE_CODE_EU_ORIGIN_11,

   '54' => MODULE_SHIPPING_UPSXML_SERVICE_CODE_EU_ORIGIN_54,

   '64' => MODULE_SHIPPING_UPSXML_SERVICE_CODE_EU_ORIGIN_65,

   '65' => MODULE_SHIPPING_UPSXML_SERVICE_CODE_EU_ORIGIN_69

	 ),

 

Are the last two lines correct?

 

Later,

Stephan


 

 

Share this post


Link to post
Share on other sites
Are the last two lines correct?

 

Those are the only two lines in the service codes arrays that changed from v1.01 and v1.02 of Torin's code.

 

The UPS XML spec shows valid service codes for EU Origin as 07, 08, 11, 54, 64 & 65. So, my guess would be that Torin corrected a bug in the numeric code values but chose not to rename the constants (which will have no ill effects except to cause confusion).

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

×