UPS XML Rates v1.3.6 for Zen Cart 1.3.9h 2011/05/08

Original Copyright of osCommerce (c) 2003 Torin Walker, 
Insurance Support 2005 Joe McFrederick,
Adapted to ZenCart 2010 Joe McFrederick,

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program.
If not, you may obtain one by writing to and requesting one from

	The Free Software Foundation, Inc.,
	59 Temple Place, Suite 330,
	Boston, MA 02111-1307 USA
Version 1.3.1 Instructions

Follow the instructions below this section for a complete fresh install.

Upgrading from 1.3.x
1. Upload files included in zip file.
2. Navigate to Admin->Tools->Packaging Options
3. In Admin, goto Modules->Shipping->UPS XML click remove. Then click Install button.
4. Goto Admin->Tools->Packing Options. Add your necessary boxes sizes. Make sure packages are ordered by shortest side by entering package cost. (ie lowest package cost = shortest product side)
5. Now go edit your products, and add product sizes to items. Please use length as longest side.
6. Goto Admin->Tools->Store Manger. At bottom click on [Optimize] database button.

Upgrading from 1.2.x or lower
1. Run only queries in packing.sql.
2. Upload files included in zip file.
3. In Admin, goto Modules->Shipping->UPS XML click remove. Then click Install button.
4. Goto Admin->Tools->Packing Options. Add your necessary boxes sizes.

	Release Notes for Zen Cart UPS XML Version
Version 1.3.6 (pickupman)
Update for 1.3.9h
Added package tables auto install themselves

Version 1.3.2 (pickupman)
Updated packing algorithm to try first fit algorithm - tries rotating package to fit
Compares volumetric compartments remaining after each product is packaged
Thanks to Mike Kalavitz for testing and giving me the idea.

Version 1.3.1 (pickupman)
Rewrote database queries to use Zen Cart db:QueryFactory syntax
Added support for Dimensional/Packing for UPS
Added language definitions for packing references
Changed packing algo to remove free shipping items from freight quote

   Release Notes from Original osCommerce version (kept for historical log)
Updated/modified/repackaged  for osCommerce 2.2 MS2 by Stuart Owens 11/14/04
Time in Transit fixed by Greg MacLellan 11/15/04
A few bugfixes and installation added to upsxml.php JanZ 11/27/04 (1.1.3)
Bugfix for ship in cart: Jackie Edwards (1.1.3a)
More options for cURL (CLI support added and logging of cURL errors) JanZ 12/18/04 (1.1.4)

Version 1.2.4 (JanZ): The services were updated according to Version 1.0, Volume 7, Number 1, Revision Date: December 17, 2006 of the Rates and Services XML Programming Information. See the file changes.txt for more detailed information on the changes.

Version 1.2:  **IMPORTANT** 
When upgrading from a version before this one (1.1.#), you *HAVE* to go into the admin, modules shipping, make a note of the settings (especially Access Key, Username and Password) and "remove" UPSXML, then upload the new version of the upsxml.php files and then install again. Otherwise the shipping options you did not wanted to offer are now the only ones offered (from version 1.1 -> 1.2). Because of new keys to be added to configuration you will also have to do this when going to 1.2.4.

Version 1.2.5 (JanZ) Bugfix release. When you have 1.2.4 or 1.2.5 installed you only need to replace includes/modules/shippping/upsxml.php and admin/packaging.php for upgrading.
Version 1.2.6 (JanZ) Bugfix release of 1.2.5. When you have 1.2.5 installed you only need to replace includes/modules/shippping/upsxml.php.
Version 1.2.7 (JanZ) Minor bugfixes for v1.2.6 of upsxml.php and admin/packaging.php (only need to replace those two files). Added instructions and files for splitting products in several items. This is a mod you can only use if you have installed the dimensions support first!
Version 1.2.8 (JanZ) Bugfixes for the split products modification of dimensions support.
Version 1.2.9 (JanZ) 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.
Version 1.3.0 (JanZ) Many changes were made. See for more information the file changes.txt.
The most important changes were the moving of the dimensional support to a separate class, so it can be used in other modules too and the way the choosing of shipping methods is done. 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(s) used for parsing the xml returned by UPS was changed in this version.
Version 1.3.1 (JanZ) Forgot to add a fix for Brazilian postcodes and outlying US territories by Steve Lionel (
Version 1.3.2 (JanZ) With directions of Steve Lionel added a sort function to sort the rates from low to high (see changes.txt for directions to sort from high to low). Only change is in catalog/includes/modules/shipping/upsxml.php.
Version 1.3.3 On suggestion of Steve Lionel the query for the zone_code was made more secure.
Version 1.3.4 Updates to the shipping module and the language module because a number of shipping options were added for some origins. In Europe Expedited was added, for Poland (domestic only) two new services were added and "other origins" had Standard added as a shipping option (for instructions on how to upgrade see a little further).
Shippers from Mexico, USA, and Canada do not need to upgrade.
Version 1.3.5 Added "Manual Negotiated Rate" setting to override negotiated rates not working for some people.

            // uncomment the next line if you get curl error 60: error setting certificate verify locations
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
            // uncommenting the next line is most likely not necessary in case of error 60
            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_HTTPPROXYTUNNEL, TRUE);
// change this->timeout = '60' around line 90 to this->timeout = '120' for GoDaddy hosting
            curl_setopt($ch, CURLOPT_TIMEOUT, (int)$timeout);
            curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
            curl_setopt ($ch, CURLOPT_PROXY, "");



In particular, I would like to thank the following individuals:
  Fritz Clapp for his UPS Choice v1.7 module, upon which I built this new module, and;
  Tom Croix for his efforts on the Canada Post 3.1 module from which several ideas were adopted.

Thanks to the many other authors before me who laid down their efforts in contributions from which I excavated the parts and
means to produce this. Your efforts are greatly appreciated.

I would like very much for this module to become a permanent resident of the osC contributions.
Your comments and suggestions are welcome and encouraged.