USPS Module Installation Instructions

USPS Module Installation Instructions

Here are the installation instructions for the USPS Shipping Module for Prestashop.  This is an advanced install and requires not just loading the module, but installing a new class and updating several others, an upgrade to an administration tab, as well as a theme upgrade and installation of a plugin for the smarty template system.

I wish it was simpler, but I have not found a way to implement all the features needed for the USPS API without all of these changes.  Core files have been edited the least amount possible to ensure operation.  The most recent release is version 0.3.2, which is a bug fix release addressing errors relating to operation with the AJAX portion of the cart module, as well as zone errors in the Carrier Admin section.

New Installation

  1. First you must get a user id from USPS.  You can do so at USPS Webtools.
  2. Now to upload files to Prestashop.  The folder called classes has three files, cart.php, carrier.php and uspsRate.php.  Upload these files to the classes folder in your prestashop installation.  Cart.php will overwrite Prestashop’s default cart.php and carrier.php will do the same.  You may want to rename those files to cart.php.old and carrier.php.old before you upload the new cart and carrier files.  Upload the entire blockusps folder to the folder called modules in your prestashop installation.
  3. There is a folder called tabs with a file called AdminCarriers.php.  The tabs folder is in your admin folder, which Prestashop required you to give a unique name when you installed your shop.  The folder named smarty has a file named compiler.continue.php.  This file goes into /tools/smarty/plugins/.  The final file is in the themes folder and is named order-carrier.tpl.  This file goes into your theme folder and replaces your current order-carrier.tpl.  This goes into whatever theme you have activated for your shop and should be compatible with most, if not all, of the currently published themes available for download.
  4. Version 0.3.1 added two new file updates.  There is a file called blockcart-json.php, that needs to be uploaded into your modules-blockcart folder.  This file only deletes extra whitespace in the prior file that I believe was contributing to the AJAX errors.  The 2nd file is only for Prestashop version 1.2.  In your main Presta folder there is order.php.  Rename your old order.php and upload the new version.
  5. Visit the Modules section in the back office of your Prestashop site.  The USPS Module should now show up under Core Improvements.  To install the module, simply click the install button next to the module information.
  6. After installing, a configure link will show up next to the USPS Plugin on the modules page.  We need to go there to configure the Module for proper operation.
  7. The configure page has USPS Account Settings on the upper left.  Please place your USPS ID next to User and your zip code (where you send packages from) in the Zip Code field.  Then click Update Settings.
  8. If you are approved for the production server, you can put the plugin into live mode.  Otherwise you will have to put it into test mode.
  9. The add a Shipping Method field allows you to choose between Priority, Express and Parcel Post.  Choose one or more and click Add a Shipping method button. –note that US is the only zone that works right now as USPS uses a different API for intl.–
  10. When you select a method it will show up in the Configure Shipping Methods field.  Here you use the select box to turn the method of shipping on or off.  You can also turn Free Shipping for that method on or off.  Free Shipping settings are input in the Shipping section of your Prestashop Back Office.
  11. If you are in test mode, run a test purchase through your shop.  On the shipping page you should get this message ** 80040b1a  API Authorization failure. RateV3 is not a valid API name for this protocol.  UspsCom::DoAuth **.  That seems like an error, but it is a successful test.  Refresh the screen several times, then e-mail or call USPS and tell them you are ready to go to the production server.
  12. If you would like to utilize the optional Box Measurement for more accurate quotes, you will need to turn it on in Account Settings.  You will also have to click the Install Box Size button, which adds fields to your product database.  If Box Measurement is active, you will have to manually input product measurements for each of the products in your Prestashop store.  You will be able to do this in the features section for the product in your catalog.
  13. The optional Machinable module works the same way as Box Measurement.  Machinable packages cost less to ship and enable your shop to show lower rates, possibly converting more sales in certain situations.  The USPS API defaults to false on machinable.  If you activate this module, you will have to update all the items in your shop with a value for machinable.  This will be done in the features section.

NOTE – If you change Free Shipping Preferences/Options (the price or weight for free shipping, not whether to offer it or not), it will take five minutes for the shipping cache to catch up to your changes.  You could optionally DELETE * FROM usps_cache in our phpmyadmin screen.

Instructions For UPS Users

1.  Follow the above instructions for a new Install.  In step 2 you need to replace carrier.php from your UPS module with the one from this module.  The USPS module’s carrier.php contains all the functions necessary to run your UPS install.  You do not need to replace cart.php as they are now the same for both plugins.  In step 3 replace AdminCarriers.php with the one from this module.  It contains all the functionality you need to operate your UPS Module.  Finally, if you are using Prestashop 1.2, replace order.php in your main Presta folder.

Instructions For Upgrade

***If you are upgrading to 0.3.2 from 0.3.1 you only need to replace Carrier.php, uspsRate.php and AdminCarriers.php.  You can replace the blockusps folder if you would like your modules page to reference the correct version number.***********

1.Uninstall the previous version of the USPS plugin on your modules page.  I will work on an upgrade script for future versions so this won’t be necessary.

2.Replace, in the classes folder, cart.php, carrier.php and uspsrate.php.  Save backups of the old files if necessary.  You will also need to add the AdminCarriers.php, as well as the update to your theme and the Smarty plugin.  Those instructions are on step 3 above.  Finally, if you are using Prestashop 1.2, replace order.php in your main Presta folder.

3.Replace the files in the folder modules/blockusps with the new folder of files

4.Follow the setup instructions from step 4 if you don’t remember how to activate and configure the plugin.

About the Author

Todd Sorensen, aka Artjunky, is a communications expert with experience in a wide array of multimedia technologies. Serving today mainly as a programmer and website consultant, Artjunky has extensive experience in live television production, photography and as a professional columnist/editor.