The shipping module for the USPS is not working correctly. In the allowed_methods field, the only choice for First-Class is only First-Class. When this is selected, it does not show up in the selectable methods on the front end. The reason is that the response returns First-Class Mail, First-Class Mail Flat, and First-Class Mail Parcel; none of which match “First-Class”.
I have hard coded the First-Class options into the database, however, if I make a change in the configuration my manual edit is over-written. Are there plans to update this piece of code or can someone point me in the direction for correcting this? I’d love to figure it out and post for everyone but am just without the time to do so.
I have found Magento to be amazing to say the least. I am picking up the framework pretty quick, I just wish I had more time to contribute.
Not sure if this helps any but the USPS code that ships with Magento can be found here app\code\core\Mage\Usa\Model\Shipping\Carrier\Usps.php I can see a few hardcoded arrays in there, but I’m in no shape to read code right now. Just figured I’d point and see if it helped anyone.
Thanks. I didn’t see where I would make any adjustments in that file, though. I could be wrong… if anyone knows of how to fix this at least temporarily please let me know. Thanks!
For anyone wanting to make this fix, it is the table called “core_config_data” in the row with a “path” of “carriers/usps/allowed_methods”. Add one or more of the below options in place of just “First-Class”
First-Class Mail Letter
First-Class Mail Flat
First-Class Mail Parcel
Thanks, Jason, for all your help. Hopefully they will have this fixed up soon.
FYI to anyone trying this: it didn’t work for me until I cleared the cache and sessions on my server and restarted Apache. (Perhaps only one of those mattered, but I decided to be thorough rather than isolate what was the minimum necessary.)
To anyone wondering what Killoff is talking about (since there’s no such file as /Usa/etc/config.xml, relative to the Magento root), the file is /app/code/core/Mage/Usa/etc/config.xml .
First-Class Mail,First-Class Mail Letter,First-Class Mail Flat,First-Class Mail Parcel
to the <allowed_methods> and the <methods> in the app/code/core/Mage/Usa/etc/config.xml file
I also updated the allowed methods in the DB, I also modified the app/code/core/Mage/Usa/Model/Shipping/Carrier/usps/Usps.php with the following
Line 322
Add to top of service array
‘FIRST CLASS MAIL’ => Mage::helper(’usa’)->__(’First-Class Mail’),
‘FIRST CLASS MAIL LETTER’ => Mage::helper(’usa’)->__(’First-Class Mail Letter’),
‘FIRST CLASS MAIL FLAT’ => Mage::helper(’usa’)->__(’First-Class Mail Flat’),
‘FIRST CLASS MAIL PARCEL’ => Mage::helper(’usa’)->__(’First-Class Mail Parcel’),
Add to top of service_to_code array
‘First-Class Mail’ => ‘First-Class Mail’,
‘First-Class Mail Letter’ => ‘First-Class Mail Letter’,
‘First-Class Mail Flat’ => ‘First-Class Mail Flat’,
‘First-Class Mail Parcel’ => ‘First-Class Mail Parcel’,
but still no luck, I get the same message everytime.
“This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.”
Can someone tell me how I can echo the XML message coming from USPS so I can see what the RAW problem is?
Try removing “First-Class Mail”, there’s no such thing (afaik) only the other three more specific kinds of first-class mail. For what it’s worth, I didn’t make any changes to Usps.php, and it’s working for me. So you might want to remove your changes to that until you get it working, and only then add them back to see what effect they have.
If it’s still not working, you could try clearing your cache, deleting the sessions on the server, and restarting your server. And dancing around the server with a rubber chicken.
Is there any way to see the RAW XML response from USPS, I want to know what’s going on! X-cart allows you to view the RAW XML response, great for diagnostics!
I have been unable to make this work so far. Very very frustrating.
method. And modified the USPS First Class options, but not even the other options work. The other thing we are not propagated yet, running on a IP number at the moment, do you think this is causing USPS to return an error?
It may be worth mentioning, for the possible benefit of newbies like myself, that you apparently need a special user account with USPS specifically to access their web APIs. I actually discovered this fact by accident after I read through this thread and tried simply unselecting the First Class Mail shipping method as an available option. That didn’t work, BTW, but it made me think I properly should try and have an authoritative list of all possible USPS package/service types in front of me before I started thrashing around in the code and/or the database for the store. So I started poking around on the USPS web site looking for their API doc’s and stumbled across the sign-up form for API access in the process—I had been trying to use our regular USPS business shipper account ID up to that point.
In case this is also news to anyone else, you can sign up for web API access by going to http://www.usps.com/webtools/ and clicking the “Access USPS Web Tools” sign-up link. They e-mail you back a user ID and PW for the test server then you have to e-mail them again to promote your account to production status. Might want to mention in the e-mail that you just want to use rate look-up and package tracking support built into a third-party shopping cart and don’t need to print labels. Otherwise you’re supposed to mail them label samples for approval and jump through more hoops for other types of service.
Anyway, I now have my USPS API account in hand, supposedly set to production status and USPS shipping still doesn’t work in Magento (darn it), so I guess I’ll go ahead and take a stab at the hacks detailed up-thread. The doc’s for the USPS rate look-up API, including that list of all possible service type responses I was looking for can be found here, BTW:
I’ve just discovered that you need the API userID instead of the regular business account ID as well. It would be nice to have that documented in the User Manual someday for other newbies.
Anyway, I am still unable to get USPS rate calculations to work too and I can’t figure out why. The only two variables that would affect this are the API UserID and the production URL (http://production.shippingapis.com/ShippingAPI.dll). If anyone can explain how they were able to get USPS to work it would be very helpful to a large amount of us who are growing quite frustrated.