Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Development] USPS Shipping Module


kymation

Recommended Posts

The current USPS shipping modules (USPS Methods, USPS Rate V4, Intl Rate V2, stock osCommerce 2.3x) all have a major problem -- they depend on the Service names that USPS supplies. Since USPS seems determined to change these names every six months or so, these modules break and must be patched twice a year. This should not happen, and it doesn't need to.

 

The quotes that USPS returns are keyed to a Service ID (called CLASSID.) These are (mostly*) unique numbers that never change, or only change when a service is deleted or added. These numbers are a much better way to select the service(s) desired, as the module will not break when USPS changes the service names.

 

If this system had been in use before the July changes, the only difference that anyone would have noticed would have been different service names showing up on the checkout page. No broken checkout, no thrashing to get a fix implemented, no lost sales.

 

I've done some preliminary testing, and I have a plan to fix this. I intend to use some of the code from the USPS Rate V4, Intl Rate V2 module since I like the way it is set up in the Admin. The rest of the code will be rewritten.

 

I have in mind an adaptive model that will require an extra step in the install process. The first edit of the module upon install will require a valid USPS Web Tools username. That will be used to send a dummy quote request to the USPS server for all available services, domestic and international. The response to that will be stored and presented in the second step as a list of services that may be selected. The selected values will then be stored in that step.

 

The installer will allow the selection of services by their current names. The names in the Admin will not change if USPS changes their API since those values are stored in the database. However, we are only comparing against the CLASSID, so the store side will continue to work and show the updated names.

 

Updating the names on the Admin side can be done by uninstalling/reinstalling the module, but that will normally not be necessary. You will only need to do that if USPS has added a new service that you want to offer to your customers or they have removed a service that you were offering. Doing an uninstall and reinstall is a lot simpler than modifying the code to make it work again.

 

*Yes, there's one problem with this approach -- the CLASSID for all First Class services is 0. That will have to be treated as a special case. That makes First Class more fragile, but USPS doesn't seem to change those services very often, so it's not likely to be a huge problem.

 

Any and all help with this is very welcome. I can use help with the code, of course, but feature suggestions and testing help are appreciated as well. Let's see what we can do with this.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Looking forward to this. Wish I could help, but testing is probably all I can do ... anyway - this sounds like the ticket for USPS. I already sent a reply to the guy that "warned" me from USPS (obviously, since I have a USPS account) - telling him I was fed up and ready to go to UPS. That's not true if you can get this to work and stop all of this nonsense that's gone to semi-annual frequency.

Edited by TomB01
Link to comment
Share on other sites

Feature suggestions are kind of trivial compared to your primary goal. :)

 

However, since you asked - it would sure be a neat trick if you could associate different shipping methods with specific products in your catalog. I have things that when sold internationally, simply have to be insured because of the $$ involved. However, Priority Mail is the minimum service that USPS allows for insurance on international shipping (in some cases, that's not even enough - it has to be Express). I kind of draw the line at about $150 - less than that, and 1st Class International without insurance is something I'm willing to accept. More than that and I'm not. I put "Priority Mail Shipping Required" in my catalog listings for those things more than $150, but that's not good enough. Some people select 1st Class anyway (because I want to offer that for lower-priced items). Then I have to contact them, explain my policies, etc., etc. and revise the invoice and ask them for an additional payment. It's a real hassle and would be easily solved if one could associate specific shipping options with a specific product.

Edited by TomB01
Link to comment
Share on other sites

Jim.. Can I "like" more than once?

 

Tom, your goals should be obtainable with the upper & lower limits per service.. however the more I read what you said, you are basing these choices on $$ and not weight.. is there a correlation that more weighted items in your store cost more??

 

What I would like to see is selectable viewing of:

weight

time and transit

(domestic & international)

insurance with lower & upper limits?

signature required with lower & upper limits?

 

obviously retail and online pricing option

 

it would be super sweet to get a label.. (but how do you guys pay when you do that?) or have the module or a supplemental module reach out to paypal multi-shipping to accomplish the label and payment of said label

 

handling fees per service is a no brainer - that's important

 

I'm trying to recall what the other options Jetta had in her 5.2x version that is different from the options available in USPS Rate V4, Intl Rate V2 version

 

 

Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Link to comment
Share on other sites

@@TomB01

The best solution would be for you to use MVS. Then you could set up a group of products that required Priority or higher, and leave the rest with First Class etc. offered. Yes there will be an MVS version of this module.

 

@@wkdwich

I planned to add a selector for show/hide weight. The time in transit is now included in the service names for most services. If that changes we may have to mess with that code, but it should be automatic if you want it. I suppose I should add a selector for those people who want that removed.

 

Insurance limits should be simple enough. Same for Signature. Retail and online is already there. Ditto for handling per service. A fixed cost/percentage handling for all services is also on my list.

 

All of these options may not be in the initial release. I try to get something basic working first, then add all the bells and whistles. It makes debugging easier.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Any and all help with this is very welcome. I can use help with the code, of course, but feature suggestions and testing help are appreciated as well. Let's see what we can do with this.

 

Regards

Jim

 

I'll test Jim, thanks for tackling this.

 

Before your post I was wondering if there was some way to get around having to manually modify the USPS module every time they make changes that changes that cause all this grief. But my limited coding skills won't cut it.

 

At least I can test....fire away.

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

Jim.. Can I "like" more than once?

 

Tom, your goals should be obtainable with the upper & lower limits per service.. however the more I read what you said, you are basing these choices on $$ and not weight.. is there a correlation that more weighted items in your store cost more??

<snip>

Hmm ... well to me it's based on $$ and how much I would lose if something happened to the shipment. Yet, you raise an excellent point. Unfortunately, there are some items I sell that are small (light) but more valuable than others.

 

I'm not complaining, though - I can live with almost any of it if Jim can get this working and stop the USPS from breaking our stores with every change.

 

 

 

@@TomB01

The best solution would be for you to use MVS. Then you could set up a group of products that required Priority or higher, and leave the rest with First Class etc. offered. Yes there will be an MVS version of this module.

 

<snip>

Is that Multi-Vendor Shipping? I don't know much about it, but I'll look into it today.

 

Referencing what wkdwich was asking up there, it's the USPS themselves that complicate this because insurance is not offered on all services with international. Priority Mail International is the absolute minimum service for insurance, but even then, they don't allow it for some countries and it requires Express Mail to get insurance (UK, Israel, for instance). There's no rhyme or reason to it, though. When I get a high-dollar sale from an international customer, I will require Priority Mail as a minimum. However, I manually check the USPS website every time just to see if insurance is offered for that country with Priority. If not, I send it Express Mail and pay the difference myself. It's usually not too much more, thankfully, because even though Express Mail is more expensive, the insurance fees are less. BTW, I don't charge my customers the insurance fees, because I feel that's for my protection, not theirs. However, the cost difference between 1st Class International and Priority Mail International is huge - I can't swallow those charges and stay in business.

 

USPS has too many items on their menu! In the restaurant business (especially fast food), there's a point where you lose control over your product when you offer too many things on the menu. I think USPS has been there for awhile, now.

Link to comment
Share on other sites

Yes, I meant Multi-Vendor Shipping. It's a bit overkill for you, but I can't think of any other way of getting what you want. Well, you could recode the USPS module to take the total order value into account, but that's a lot of work. Especially for one of these old modules. It will probably be easier when I manage to get something coded to a more modern standard.

 

I agree that the USPS has way too many options that are confusing their customers. Then they change names that have been recognized for over a century (Parcel Post to Standard Post? Really?) Unfortunately there's nothing I can do about that. Automating this properly is going to mean presenting every option to the store owner in the Admin. You'll just have to sort through it all and select the options that make sense to you.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Yes, I meant Multi-Vendor Shipping. It's a bit overkill for you, but I can't think of any other way of getting what you want. Well, you could recode the USPS module to take the total order value into account, but that's a lot of work. Especially for one of these old modules. It will probably be easier when I manage to get something coded to a more modern standard.

 

I agree that the USPS has way too many options that are confusing their customers. Then they change names that have been recognized for over a century (Parcel Post to Standard Post? Really?) Unfortunately there's nothing I can do about that. Automating this properly is going to mean presenting every option to the store owner in the Admin. You'll just have to sort through it all and select the options that make sense to you.

 

Regards

Jim

 

Agreed - I was mainly just venting about USPS. It doesn't matter how long the options list is, I can muddle through it. It must complicate everything unnecessarily, though - not only for post office customers but for developers like you.

Link to comment
Share on other sites

@@burt

Are you moving across the pond? I didn't think the USPS allowed you foreigners to sign up. :)

 

Seriously, all help is welcome. I'll post up some code as soon as I have something that you can try out. All I have so far is a hacked script that tells me it'll take four requests to the USPS server just to get the data to install. Fun.

 

Regards

Jim

Edited by kymation

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

That's what I originally thought, but USPS refuses to give me all of the data at once. So I have:

  1. Request quote for all services to an arbitrary domestic zip code. This returns services but not extra services.
  2. Request quote for all of the above services. This returns the extra services.
  3. Same as #1 for international.
  4. Same as #2 for international.

So it goes.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Then you should probably post a request for help in the general forum, or in the Commercial forum if you want to hire someone to fix this for you. This forum is for the development of new software.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

In another conversation, I noted that I liked the feature set in USPS Methods 6.1. I don't use all of them, of course, so here's my list of preferred features:

 

1. Enable USPS Shipping (basic)

2. USPS User ID (basic)

3. Tax Class - I have to charge tax for orders in my state

4. Display Options:

4.a. Weight

4.b. Transit Time (this is important, but transit time in days is best - not some "will arrive on date." That's guaranteeing a delivery time even before I ship - can't do that.)

4.c. Tracking (formerly Delivery Confirmation), if this gets too complicated, I can live with selecting tracking or not for all services. It's really only a chioce for 1st Class Domestic packages - everywhere else it's automatically included. It's nice to show the customer whether tracking is included in the checkout, though.

5. Domestic Shipping Methods - Express Mail (now Priority Express?), Priority Mail, First Class Mail (package or parcel, whatever it's called now), Standard Post (used to be Parcel Post). For my store, I don't use letters or flat rate options. I can't predict what type of box will hold an order, so can't let my customer choose which flat rate box he/she wants. The new services of "Hold for Pickup" are not applicable to me, either. I'm not sure about Regional Rate boxes - sounds way too complicated right now.

6. Domestic Flat Handling Fees - This is very helpful. I like the ability to charge less of a handling fee (package costs, etc.) for 1st Class (weight-limited) versus Priority and Express. However, the Methods 6 was very awkward with this. If you down-selected to a few shipping methods, this field continued to list values for every single service. You couldn't tell which value in the array to place the handling fees for the services you selected.

7. Domestic Rates - Retail is what I need.

8. Domestic Delivery Confirmation - this has changed to USPS tracking. Given a choice, I would rather default to all packages. It really only makes a difference on 1st Class Domestic packages - all others include it in the price.

 

Insurance and weight limits - I don't let my customers select insurance (I pay it myself as a cost of business), so an ability to turn this off is needed. If there was a way to force a minimum service on a specific product or $$ total, that would be helpful - something like a Priority Mail $$ threshold? I've mentioned this before, but insurance is not available on international shipments with 1st Class. It's not available for Priority with some countries, either, but the price difference between Express (all countries offer insurance) and Priority is not so hard to bear. Anyway, it's not critical and I can handle it manually as I've done for the last ~7 years.

 

Weight limits - not sure why this was selectable in Methods 6. USPS has specific limits (the contrib should read those or usps.php should default to the known values) and if those are exceeded, then the in-applicable service selections should not show. In my business, the only place this is important is with the limit of 1st Class - beyond a certain weight, it must be Standard Post or Priority. As stated, this is a USPS decision, not ours.

 

9. International Shipping Methods - More or less the same as Domestic: Priority Express (same as previous Express Mail?), Priority Mail International, First Class International Package (Parcel).

10. Same as Domestic above - the ability to charge a lower handling fee for small 1st Class packages versus larger Priority boxes is a good thing. However, same complaint - the array stayed the same size in Methods 6 as the entire gamut of shipping methods offered by USPS. You couldn't tell where in the array to place the fee amounts for the shipping methods you down-selected.

11. International Rates - I use Retail

12. Handling Fees Charged - per shipment (I guess some people want to charge per catalog item, but I don't need that - per shipment or order total is fine.)

 

I think that does it, but it's hard to tell with so many new shipping methods and name-changes by the USPS.

Edited by TomB01
Link to comment
Share on other sites

Sorry, I forgot - the reason the arrays were hard to read is because my Admin Edit for this simply doesn't work when I went to Methods 6. I use OsCommerce 2.2 and was told at the time that the Admin interface was no longer compatible with the php used on my hosting server. So, I have been manually punching the settings into the Configuration table via phpMyAdmin.

Link to comment
Share on other sites

@@TomB01

1 & 2. Of course.

3. Good one. Added to the list.

4a. Weight optional is already on the list.

4b. Transit time is now embedded in the service name (!!!) in most cases. I don't know what we could do about the ones where it's not provided.

4c. It's a "Special Service" so you can select it in the Admin. It isn't mentioned anywhere on the catalog side.

5. You'll get to chose from whatever is offered on the Admin side. The offered services are automatically generated.

6. There is a flat or percentage fee to add to all services, and a flat fee that can be added to each service individually. The interface will be as used in the USPS V4 module.

7. Retail or Online will be a choice in the Admin.

8. Special Services again.

? Insurance is a special service, so it's either on or off. If on it only applies where USPS allows it to be. Weight limits are for sellers who wish to limit the products they will ship by USPS. Anything over the limit set could not be shipped USPS, so the customer would have to select UPS/FedEx/whatever.

9. Again, you get whatever USPS offers, and can choose from that.

10. Same as #6.

11. Same as #7.

12. #6 again.

 

Thanks for the good suggestions. As I stated before, the first release will probably be pretty basic, and will be just for testing. I'll add all of the bells and whistles after I know the basic module is working.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Good comments! Yes, I thought the transit times were in the service names. When attempting bkpie's temp fix using 5.2, though, I noticed that 5.2 must've been using some string calculations to turn the service transit time into a delivery date ... not good from my perspective.

 

I can't believe all these service changes/adds from USPS - the postal clerks are going to go dizzy with all this stuff.

Edited by TomB01
Link to comment
Share on other sites

I'm trying to avoid using the service names for anything. I still have to do it for First Class, but anywhere else they can change all the names they want and nothing will happen.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

I've set up a development addon here. This currently only contains a test file that I used as a feasibility study. It returns the domestic and international codes and names for all services and special/extra services.

 

Everyone is welcome to download and look at this. There are instructions in the comments at the top of the file. Note that it needs a valid USPS Web Tools username that is cleared for the production server. Any code/suggestions for improvement are always welcome. The code in this file has been moved into my skeleton module, and will be used to power the installer.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

@@kymation

 

Jim I installed and ran this. Got quite a list of array results. You want that emailed to you or what?

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

No, just take a look at it and see if you can spot any errors. You can also play with the origin and destination codes and see if anything changes. The goal here is to get a complete list of services to stuff in the installer.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

No, just take a look at it and see if you can spot any errors. You can also play with the origin and destination codes and see if anything changes. The goal here is to get a complete list of services to stuff in the installer.

 

Regards

Jim

 

OK...no errors jumping out so I'll make changes as above and see what happens. Thanks

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

It tested some shipping destinations to countries in the middle east. No problems with the code but now I have an NSA van parked outside my house. o:)

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...