Jump to content
kymation

[Development] USPS Shipping Module

Recommended Posts

So I need to go figure out the secret code to get First Class package service working. Lovely.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

I feel your pain.

Edited by altoid

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.

Share this post


Link to post
Share on other sites

I found this document on USPS.com which has all the class id or service id: https://www.usps.com/business/web-tools-apis/2013-july-webtools-release-notes.rtf  See appendix A in the RTF document. I also spoke to USPS webtools this evening and they will be changing USPS First Class Mail to First Class Package Service. This First Class Package Service is service / class id 61, which is being returned with quote of zero. When this id 61 is enabled it might start working? I am calling back to USPS' Web Tools Technical Support hotline to see if they can give us the release date on this upcoming change. I will also reach out to this other resource: http://docs.rocketship.it/php/1-0/usps-class-ids.html

Share this post


Link to post
Share on other sites
Currently class/service id for First Class Mail is 0 , but have to specific the RateV4Request / Package / FirstClassMailType

First-Class Mail Large Envelope

First-Class Mail Letter

First-Class Parcel

First-Class Mail Postcards

Share this post


Link to post
Share on other sites

I have that document and have been reading it. It tells me all of the new services that have been added, but it doesn't tell me the magic data that I have to send to make them return a quote. CLASSID 61 is currently active and returning a quote of $0.00 with no error message. This is not helpful. If it is not supposed to be live it should return nothing or an error message.

 

Please let me know if you find any useful information on this.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

Jim,

 

I have opened a case with USPS Webtools Incident: 150326-000440 and if you can send them the XML request to their email address: USPS Technical Support <uspstechnicalsupport@mailps.custhelp.com>

 

Thanks,

Craig

Share this post


Link to post
Share on other sites

I just dropped .8 into my development directory, and if I leave admin set to residential...nothing shows at all on customer side.  If I switch to commercial, then I see the "United States Postal Service" section, but no shipping types or prices.

 

I did get emails for every time I refreshed the page.  I'll attach the request as a text file, but the part that interested me was the last line:

 

"-2147221202Common:XmlParseThe element 'RateV4Request' has invalid child element 'Package'."

 

 

 

 

full text:usps_error_mail.txt

 

I'm sure I've goofed something up here, but I'm not sure what it is.  I used winmerge to modify the modules.php file, as mine had other modifications in place for the original USPS Methods contrib.  My checkout_shipping is modified as well, but it seems like this produced more customer-side output last time I installed it.

 

 

Share this post


Link to post
Share on other sites

@@Supertex  Apparently the USPS has done something again, and I haven't figured it out yet. That error message is useless (and wrong as well, if you read their API documentation). I'm working on it. So no, it's not you, it's the USPS.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

Likely another USPS change. I'll take a look as soon as I get a chance. Busy putting out client's fires right now....

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

@@kymation  Jim, I realize this version is development, but do you see any reason not to try it on a live shop?  I have a bootstrap shop I'd like to get USPS shipping running in.


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.

Share this post


Link to post
Share on other sites

You can try it, but no guarantees that it will work at all. The USPS seems to be tinkering with their API again. Of course that means that all of the modules are at risk. Nothing is safe where the USPS is involved.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

I've been turning off methods that I don't use, and ran across a problem.

 

For domestic, Priority Mail is the only option I offer.  But when I do that, the shipping page goes entirely white, like the code is broken.  As near as I can tell, it seems not to like only allowing one option.

 

If I turn on Priority mail and ANY other domestic option, it works.  But if I cut it back to a single option (regardless of which option, it seems) the screen goes white again.

 

Another log for the fire.

 

:)

Share this post


Link to post
Share on other sites

Please check your error log, or turn on error display in your template_top.php. I need to know what these errors say, since this doesn't happen on my test server.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

You can try it, but no guarantees that it will work at all. The USPS seems to be tinkering with their API again. Of course that means that all of the modules are at risk. Nothing is safe where the USPS is involved.

 

Regards

Jim

 

Understood.  I'll install that.  I'll have a second shipping option in place just in case of what you mentioned.  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.

Share this post


Link to post
Share on other sites

Here is an error email from today:

 

The response from the USPS was empty. This could be a fault in the USPS server, or there is something very wrong with the request.
Request: API=RateV4&XML=%3CRateV4Request+USERID%3D%22(omitted)%22%3E%3CRevision%3E2%3C%2FRevision%3E%3C%2FRateV4Request%3E
Response: 
-2147221202Common:XmlParseThe element 'RateV4Request' has incomplete content. List of possible elements expected: 'RateClientType, Package'.
Request: API=RateV4&XML=2
Response: 
-2147221202Common:XmlParseThe element 'RateV4Request' has incomplete content. List of possible elements expected: 'RateClientType, Package'.

 

 

 I don't know how to enable error display in template_top, but if you can tell me how, I will certainly make the changes.

 

Also, I mispoke when I said having any single method would cause the page to go white.  This morning, I went in and turned all methods off, and then turned them on one at a time.  All of the FCM methods worked fine when they were the only method.  The white page started with Library Mail Parcel.  Beyond that, I checked Media Mail, & Priority Mail.  But when I went to enable Priority Mail FR Env, the admin module lost everything after Standard Post...options disappeared, nothing for international, nada...the list just ends.  There's not even a "save" button.

 

So, I uninstalled, and reinstalled the module.  I noticed that after it acquired methods, the list stopped after Priority Mail Express 1-Day™ Padded Flat Rate Envelope Hold For Pickup.  Some of the options that were there before, including "Standard Post" are just gone from the list.  But new methods like FCM Stamped Letter had appeared.

 

So I guess they're still screwing with it.

Share this post


Link to post
Share on other sites

In includes/application_top.php find this line:

// set the level of error reporting
  error_reporting(E_ALL & ~E_NOTICE);

and change it to:

// set the level of error reporting
  error_reporting( E_ALL );
  ini_set('display_errors', '1');

This will display all errors if possible. Sometimes errors still do not show due to broken HTML, so if you still see a white page, use View Source to look at the error message.

 

The USPS has added a limit of 25 services per request. Since they have more than 25 available, we only get the first 25. I'll have to code up a multiple request to get around this. They just keep making it harder for their customers to do business.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

It looks like you've got a bunch of duplicate entries in the database. Try this:

  1. Uninstall the module.
  2. Check that the usps_codes table in the database is empty. if not, truncate it.
  3. Search the configuration table for anything containing USPS_CODES and delete any lines found.
  4. Reinstall the module.

Regards

Jim


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

Share this post


Link to post
Share on other sites

I uninstalled, verified the USPS_codes table was empty, and then verified no %USPS_CODES% configuration entries.  Reinstalled, added Webtools ID, saved.

Then deselected all domestic methods except priority, saved again and got the white page with this:

 

Notice: Constant FILENAME_FREE_SHIPPING already defined in /path/includes/filenames.php on line 85 
Notice: Use of undefined constant choose_insurance - assumed 'choose_insurance' in /path/checkout_shipping.php on line 55 
Notice: Undefined index: choose_insurance in /path/checkout_shipping.php on line 55 
Notice: Use of undefined constant usps_codes - assumed 'usps_codes' in /path/includes/modules/shipping/usps_codes.php on line 105 
Notice: Only variable references should be returned by reference in /path/includes/classes/xml_5.php on line 86 
Fatal error: Cannot unset string offsets in /path/includes/modules/shipping/usps_codes.php on line 1932
 
Turning on Priority Express in addition to Priority restored page function, and changed the output to :
 
Notice: Constant FILENAME_FREE_SHIPPING already defined in /path/includes/filenames.php on line 85 
Notice: Use of undefined constant choose_insurance - assumed 'choose_insurance' in /path/checkout_shipping.php on line 55
Notice: Undefined index: choose_insurance in /path/checkout_shipping.php on line 55 
Notice: Use of undefined constant usps_codes - assumed 'usps_codes' in /path/includes/modules/shipping/usps_codes.php on line 105 
Notice: Only variable references should be returned by reference in /path/includes/classes/xml_5.php on line 86
Notice: Undefined variable: extra_name in /path/includes/modules/shipping/usps_codes.php on line 611 
Notice: Undefined variable: extra_name in /path/includes/modules/shipping/usps_codes.php on line 611 
Notice: Constant MODULE_BOXES_INFORMATION_BOX_CONTACT already defined in /path/includes/languages/english/modules/boxes/bm_information.php on line 21

Share this post


Link to post
Share on other sites

Three of those errors are unrelated to this module:

  1. FILENAME_FREE_SHIPPING is defined twice in /path/includes/filenames.php. Delete one of the defines.
  2. MODULE_BOXES_INFORMATION_BOX_CONTACT is defined twice in /path/includes/languages/english/modules/boxes/bm_information.php. Delete one of those defines.
  3. /path/includes/classes/xml_5.php is being used by another module, probably an old version of UPSXML. There are fixes for this in the support thread.

One of the remaining errors was me forgetting to quote a text string. Doh. Fixed.

 

I will need to look at the rest. I think the problem, or at least part of it, is due to requesting more than 25 services at one time. This will take a bit of work to fix. I need to have the code split the request and then recombine the result. Not fun.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

Jim, just FYI

 

Warning: constant(): Couldn't find constant MODULE_SHIPPING_USPS_CODES_DOMESTIC_SERVICES_61_HANDLING in /home/username/public_html/includes/modules/shipping/usps_codes.php on line 524


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.

Share this post


Link to post
Share on other sites

Class 61 seems to have disappeared again. I should probably do something about those errors in case they do this again. Which they will.

 

Thanks for the bug report.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

@@Supertex  I could do that. It probably won't make it into the first release though. I'm having enough trouble trying to reverse-engineer the USPS API as it is.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×