Contributions
UPS XML Rates and Services v1.0
The long awaited UPS XML Rates and Services shipping module. You must obtain an access key and account from UPS before using this module.
This is relase 1.0 and should be considered very beta.
I will support any and all suggestions and bug fixes that come my way.
I hope you enjoy.
Torin...
Expand All / Collapse All
Fixed a bug where UPSXML was changing the value of $shipping_num_boxes provided by osCommerce without ever using the changed value. This was causing problems with the USPS shipping module.
In testing the packaging with an order for a large number of "ready to ship" products I discovered that the UPS rates tool cannot process a shipment with more than 50 boxes. While it isn't likely that anyone will actually place an order that will be divided into more than 50 boxes we still don't want an error message returned if such an order does get placed. I therefore added code to the _upsGetQuote routine to split such orders into groups of 50 boxes in order to retrieve all of the quotes and then more code in the parseResult routine to combine the multiple shipment quotes into a single set of rate quotes so that service types aren't listed more than once.
Added code to display the billed weight for each service (the dimensional weight) if weights are being displayed.
Note: The only changes were made to the two upsxml.php files. If you already have version 1.3.6 installed you can simply replace those two files and be done since no configuration variables were changed from version 1.3.6.
Small bug fixes for example using exec with curl no longer gave shipping quotes because of a small change in the UPS API for Rates. When a line break was added after <?xml version="1.0"?> in the Rates reply suddenly the array that curl using exec returns contained in array[0] the <?xml version="1.0"?> and in array[1] the rest of the message.
See changes.txt for more details.
In upsxml.php, find (line 345) :
if ( ($this->manual_negotiated_rate > 0) && ($this->use_negotiated_rates != 'True') ) {
$cost = ($this->manual_negotiated_rate * $cost)/100;
}
and change 'True' to 'False' so it look like :
if ( ($this->manual_negotiated_rate > 0) && ($this->use_negotiated_rates != 'False') ) {
$cost = ($this->manual_negotiated_rate * $cost)/100;
}
Also, for some reason I was getting a rate from Canada to US without any name but with a quote. After this line :
// changed to make handling percentage based
if ($this->handling_type == "Percentage") {
you find 2 lines starting with $methods[] = array('id' .....
simply add at the beginning of those 2 lines (350 & 352) : if ($_type) so it look like :
// changed to make handling percentage based
if ($this->handling_type == "Percentage") {
if ($_type) $methods[] = array('id' => $type, 'title' => $_type, 'cost' => ((($this->handling_fee * $cost)/100) + $cost));
} else {
if ($_type) $methods[] = array('id' => $type, 'title' => $_type, 'cost' => ($this->handling_fee + $cost));
}
Full 1.3.5 package with bug fixed
Marc
Normally I loathe people releasing a new contribution version with one little fix but I thought this was well worth it.
Have you had trouble with UPS supporting your account's negotiated rates? Does your online account lack reflection of negotiated rates? Fear no more. I ran into this issue with a client and added this small hack.
It adds a config field in the admin panel for setting a manual negotiated rate percentage and adjusts the shipping accordingly.
Thanks to HanZ it was found that the UPS XML module was not up-to-date anymore regarding the shipping options. In Europe Expedited was added, for Poland (domestic only) two new services were added and "other origins" had Standard added as a shipping option.
Shippers from Mexico, USA, and Canada do not need to upgrade.
As proposed by Steve Lionel the query for the zone_code was made more secure (only file changed includes/modules/shipping/upsxml.php)
With directions of Steve Lionel added a sort function to sort the rates from low to high (if you want that vice versa you will need to change one line in the shipping module). Only change is in catalog/includes/modules/shipping/upsxml.php.
Forgot to add a fix for Brazilian postcodes and outlying US territories by stevel which is dealt with by changing the function _upsDest($city, $stateprov, $country, $postal). Only file changed is catalog/includes/modules/shipping/upsxml.php.
Many changes were made but only minor improvements to the functionality. See for more information the file changes.txt. For upgrading see the readme.txt, lines 42-61.
The most important modifications are the moving of the dimensional support to a separate class, so it can be used in other modules too and the way the selection of shipping methods to offer is done in the admin. The addition of a function to an admin file and a change to the database is no longer needed. This inevitably caused problems for a few people.
Also the file used for parsing the xml returned by UPS was changed in this version. This will be noteworthy if you use negotiated rates (no errors when none are returned).
A quick fix for weight displyed as 0 if total weight is less than 1 (lbs/kg). This is because of rounding thats being done without any decimal digit.
In modules->shipping->upsxml.php
Find
$upsQuote = $this->_upsGetQuote();
2 lines below there are 2 statements starting with
$this->quotes = array('id' => $this->code,
within these lines is code snippet
round($totalWeight,0)
Change the 0 to number of decimal digits to round to
round($totalWeight,2)
This will display weight rounded to 2 decimal places like 0.20 etc.
Same insturctions in the uploaded file
In the last contribution UPSXML_v1_2_9
A line is missing from the catalog/includes/module/shipping/upsxml.php
Added support to store the results of the packaging algorithm in the database (only useful when you use dimensions support.) See changes.txt and store_ups_boxes_used_instructions.txt for more details.
For all of you that use GoDaddy as your hosting company. I searched for hours and days trying to find the solution to the timeout error. Its simple, thanks to JanZ; Simply add the following lines in catalog/includes/modules/shipping/upsxml.php after the following:
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest);
curl_setopt($ch, CURLOPT_TIMEOUT, (int)$timeout);
curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
add these lines:
//GODADDY STUFF
curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt ($ch, CURLOPT_PROXY, "http://proxy.shr.secureserver.net:3128");
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_TIMEOUT, 120);
//END GODADDY STUFF
That solved my problem, hope it solves yours!
Ok folks, Now if you install this module and then your page does not load at all you need to go to the includes/modules/shipping/upsxml.php file and go to line 98 and change the 0 to a 1.
This will fix your problem and let me tell you it is not noted anywhere and is a headache to find without docs.
So here it is a simple fix that will get the system working if you do not have CurL compiled. Some of you might think you do but do this anyway before pulling your hair out!
Example of the code:
// to enable logging of just the errors, do as above but call the file upsxml_error.log
$this->ups_error_file = '/home/lotiocom/public_html/upsxml_error.log';
// when cURL is not compiled into PHP (Windows users, some Linux users)
// you can set the next variable to "1" and then exec(curl -d $xmlRequest, $xmlResponse)
// will be used
$this->use_exec = '1';
=============================
NO FILES TO DOWNLOAD JUST READ ABOVE!
Minor modification to the latest version of 1.2.8. Added a configuration value to the /catalog/modules/includes/shipping/upsxml.php file so that you can easily choose whether or not to display time in transit from the admin control panel. Full installation is enclosed but only the /catalog/modules/includes/shipping/upsxml.php file has changed. To use this modification if you already have this version 1.2.8 of this contribution installed simply uninstall the shipping method, replace the /catalog/modules/includes/shipping/upsxml.php file, and reinstall the shipping method.
Some bugfixes for the split product modification of the dimensions support (admin side only).
Some small bugfixes to the dimension support part. Added instructions and files to extend dimensions support with the ability to split products in several items for packaging (screenshot included).
For upgrading from 1.2.6 to 1.2.7 you only need to replace catalog/includes/modules/shipping/upsxml.php and admin/packaging.php. To add the splitting of products follow the instructions in the file split_products_instructions.txt (after having added dimensions support).
This version is again a bugfix release. There is a bug in version 1.2.5 with regard to ready-to-ship items in the packProducts function (when you use the dimensions support) which got ignored.
For upgrading from 1.2.5 to 1.2.6 you only need to replace catalog/includes/modules/shipping/upsxml.php.
This versions is a bugfix release. There is a serious bug in version 1.2.4 with regard to sorting ready-to-ship items (line 248 in /shipping/upsxml.php). Additionally some changes in the packaging algorithms were made, to deal with products that do not fit the largest box, but do fit in one of the smaller boxes (for example long, thin items). This used to result in becoming them ready-to-ship items.
Small bugfix in admin/packaging.php that resulted in not being able to edit or delete certain boxes.
For upgrading from 1.2.4 to 1.2.5 you only need to replace catalog/includes/modules/shipping/upsxml.php and admin/packaging.php.
Update for changes in services going into effect January 2, 2007. Fixes in the insured value added, possibility added to get quotes for your negotiated rates (if you have those). Some changes in the code to do less calculations when fitting products in boxes (when you use dimensions support).
The text file contains instructions on how to modify upsxml.php in the [osCommerce_web_root]/includes/modules/shipping folder in order to add insurance to your packages. See file for details.
Forgot to change the title in last addition . Same instructions same package.
Corrected the mispelling of height was (heigth) in includes/modules/shipping/upsxml.php in the getPackagesByVol() function. This would only affect shops using dimensions support. Great work JanZ and mucter. This is the FULL package.
To upgrade from 1.2.2 to 1.2.3 replace includes/modules/shipping/upsxml.php
Corrected the mispelling of height was (heigth) in includes/modules/shipping/upsxml.php in the getPackagesByVol() function. This would only affect shops using dimensions support. Great work JanZ and mucter. This is the FULL package.
To upgrade from 1.2.2 to 1.2.3 replace includes/modules/shipping/upsxml.php
Correction of an error in the function getPackagesByVol() (includes/modules/shipping/upsxml.php) where the volume was queried as length*width*length where it should have been length*width*height.
Updating from 1.2.1 to 1.2.2: just replace includes/modules/shipping/upsxml.php
A small update to JanZ's version 1.2 of this module.
- added the ability to choose the time in transit display being either the raw style or the more readable version from the admin tool instead of having to edit the code.
- created a workaround for when the total weight of all boxes is greater than the maximum weight for time in transit in either lbs (150) or kgs (70). It will limit the weight to the maximum just for time in transit (will not affect shipping wieght).
- Added the ability to define handling fee as either a Flat Fee or a Percentage throught the admin screen.
NOTE: as with version 1.2, in order to get the new features in 1.2.1 you will need to remove/install the module in the admin screen.
This version contains updated UPS services (several ones used outside the US were not up-to-date anymore), an improved packaging algorithm (no more disappearing items), more options and checks when using the dimensions support and the possibility to get UPS errors emailed to the shop owner (and/or logged to a logfile).
When updating from an earlier version, make notes of your settings and "remove" and "install" UPS XML in the admin section. Do not just upload the new files!
I spent 3 days trying to get the proper product weight to appear at check out and to be sent to UPS for a proper shipping rate to be returned. Thanks to falsedawn and JanZ in helping to get these two great contributions to function correctly. This may work for other shippers as well.
This fixes a bug which I encounterd. Could be because my site is heavily modified but here's a fix.
The ready to ship checkbox isnn't checked when it should. When it's checked and saved, the value is not saved.
Change in categories.php
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_checkbox_field('products_ready_to_ship', $pInfo->products_ready_to_ship); ?></td>
in:
<td class="main"><?php echo
tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' .
tep_draw_checkbox_field('products_ready_to_ship', '1', (($product['products_ready_to_ship'] == '1') ? true : false)); ?></td>
Added support for insured rate for the cart value. Can be enabled/disabled from the admin menu.
If updating from a previous installation, click the remove button in admin. Upload /catalog/includes/modules/shipping/upsxml.php
Click on Install button in admin. Setup values.
Some changes were made in the _post function to be more flexible using cURL (option added to use cURL through exec(), this is the command line interface (CLI)) and to log cURL errors when possible.
Fixed a small bug where it was causing shipping_estimator to double shipping price in order total.
SEE changes.txt for more details
Only corrected a logic error I introduced. It would have been a problem if the TimeinTransit module didn't return anything.
Complete package again of version 1.1.1 with Time in Transit patch of Greg MacLellan. The install sql of that patch is intregrated in the code now. Additionally, bugfixes for CURL that caused some servers to throw errors and a bugfix for the Time in Transit patch that caused checkout_shipping to reload forever.
Nothing creative really. All honours go to previous authors.
Sorry to release again so soon, but made some changes:
Now has a "shipping delay" option so times can be estimated based on shipping tommorow (configurable).
This file contains the patch to the original version 1.1.1, and the replaced (already patched) upsxml.php file
This is a patch (unified diff) that appends the estimated arrival date to each shipping method displayed, using the transit time XML service.
The original code had the capability to get the transit time, but was commented out by default, and only selected the transit time for "GND" service (which doesn't seem like it would work - it looks like UPS returns either a numeric code, or the full text "UPS Ground") regardless of the service (ie, ground time is not the same as Air time).
Complete package
Minor Update correcting the following. If you already have v1.1, you can just make the changes noted below:
Changes from 1.1 to 1.1.1
------------------------------
1. Corrected misspelling in catalog/includes/modules/shipping/upsxml.php line 647:
$sheduledTime = $ratedShipments[$i]->getValueByPath("/ScheduledDeliveryTime");
corrected to read
$scheduledTime = $ratedShipments[$i]->getValueByPath("/ScheduledDeliveryTime");
2. In catalog/admin/packaging.php, there were 2 instances where a "$error" had somehow crept into the code:
Line 196
function showNewPackageForm($error) {
corrected to read
function showNewPackageForm() {
and line 225
function showUpdatePackageForm($error) {
corrected to read
function showUpdatePackageForm() {
Complete package
1. Reformatted files. Line numbers may not match previous versions. Functionality unchanged
2. Set Time In Transit to be disabled by default - Simple change to 4 lines required in upsxml.php in order to enable
explained in readme.txt
3. Fixed bug that would yield inaccurate package count (and rates) in certain circumstances where a cart had mixed
"ready-to-ship" and non "ready-to-ship" products.
4. Removed "include(DIR_WS_CLASSES . 'htaccess.php');" from catalog/admin/packaging.php
(no one has ever figured out why it was there in the first place)
Full package included in this download
Correction to version ID and mis-spelled text define
see http://forums.oscommerce.com/index.php?showtopic=49382&view=findpost&p=470198
Thanks, Jan!
Full package included in this download
Correction to version ID and mis-spelled text define
see http://forums.oscommerce.com/index.php?showtopic=49382&view=findpost&p=470198
1) Added capability to choose which options will be offered to customer. Configurable in the Admin area
2) Fixed Time In Transit bug that was showing an error for international shipments
3) Updated install instructions for MS2 in both upsxml and packaging modules
Support thread: http://forums.oscommerce.com/index.php?showtopic=49382&hl=
TO DO:
Improve Time In Transit International - while error no longer appears, there are no transit times being displayed for anything other than domestic shipments. (Anyone can feel free to tackle this, it's not anywhere close to the top of my TODO list)
Just a small update, hope no-one minds... It will help others that do a 'basic' install...:
*PRELIM* Changes for 1.03.02
1. Adjusted ZIP package layout so files/directories are in their proper places.
2. Modified the two 'xmldocument.php' script to prevent the warning messages:
Warning: Call-time pass-by-reference has been deprecated - argument passed by value;
If you would like to pass it by reference, modify the declaration of
[runtime function name](). If you would like to enable call-time
pass-by-reference, you can set allow_call_time_pass_reference to true in your
INI file. However, future versions may not support this any longer.
3. Modified the upsxml.php script to defaut DIMENSIONS_SUPPORTED to '0' instead of '1' to
work 'out-of-the-box', as instructions imply.
4. Modified the upsxml.php script to comment out logfile. It was enabled, and very few (read: 1)
folks have the default logfile path.
Drop me a line if any issues with items I did.
Gratzi!
Me.
Fixed bug if customer put in wrong zipcode for Time in Transit.
Made the pickup date the current date.
Added UPS Ground Time in Transit functionality to base package.
Fixed bug caused by the following in /includes/languages/english/modules/shipping/upsxml.php
<sup>SM</sup> and @reg;
This is my first contriubtion so please bear with me :)
Fixes the most notable bugs (see changes.txt), and adds commercial/residential quoting, and customer classification.
Update to the first UPS XML Release. Fixes a few bugs, making it much more stable. More features added to the dimension support (if you should choose to enable it.)
The long awaited UPS XML Rates and Services shipping module. You must obtain an access key and account from UPS before using this module.
This is relase 1.0 and should be considered very beta.
I will support any and all suggestions and bug fixes that come my way.
I hope you enjoy.
Torin...
Note: Contributions are used at own risk.