Categories
Programming

USPS PHP Class

The shopping cart that I wrote some time ago has used rate and zone tables that were loaded into the local database.  The USPS rate and zones have been harder to get in CSV (comma separated variable) format for the last couple of years.  It was now time to drop the local rate charts and use the USPS online tools.

The USPS tools are nice in that they use XML to format both the request and the results. You format a request with your USPS User ID, the originating ZIP code, the destination ZIP code and the package weight and the tool returns a list of the available services and rates. This is nice, except that my old shopping cart expects to make a rate lookup for each service that it supports. I didn’t want to overload the USPS online tool. This class will cache the results of a rate request for a ZIP code and weight combination.  Create an instance of this class early in your PHP module. I used the object as a global data structure. At the point were I needed to do the rate lookup, it was easy to access the data.

$rate = $usps->GetRateUS_byService($dest_zip, $weight, 'Parcel Post');
$rate = $usps->GetRateUS_byService($dest_zip, $weight, 'Priority Mail');

If anyone has any improvements I would be interested in seeing them.

uspsTools.tar.gz

Categories
Cooking

Northern Style Cornbread – By Weight

I love my daughters, but they drive me crazy. Nothing in the kitchen seems to end up where I think it should be.

My wife asked me to bake something over the weekend.  I decided to make her Corn Bread From Scratch recipe. As I started working in the kitchen, I couldn’t find the measuring cups that I needed for the recipe. “Honey, where is the 2/3 cup measure? I can’t find it.”  Blast!

Categories
Personal

Sum’ar Beard

During the Christmas vacation I ended up with a really nasty cold.  When you are sick you find that your energy levels are just too low to do much of anything.  Shaving was just one thing too much for me.  After about a week, I was feeling better.  However my youngest daughter wanted me to let my “beard” grow.

The results after about 2-1/2 weeks was this Sum’ar Beard.  You know, som’ar here and som’ar there.  I think that it makes me look more like a homeless tramp than a rugged outdoorsman.  Do not expect to see facial hair on this face anytime soon.