Forums / Addon Shipping Modules / USPS Shipping (RESTful) (USPSr)

USPS Shipping (RESTful) (USPSr)

Sticky

Views: 54,966

Results 481 to 500 of 558
26 Feb 2026, 11:58 PM
#481
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

USPS Shipping (RESTful) (USPSr)

siliconbug:

v1.8.2 also causes another error on ZC 1.5.8 w/ php 8.2:

Request URI: /shEet-CCW-clIff/index.php?cmd=modules&set=shipping, IP address: x.x.x.x, Language id 1
#0 [internal function]: zen_debug_error_handler()
#1 /zc158/includes/classes/db/mysql/query_factory.php(667): trigger_error()
#2 /zc158/includes/classes/db/mysql/query_factory.php(634): queryFactory->show_error()
#3 /zc158/includes/classes/db/mysql/query_factory.php(275): queryFactory->set_error()
#4 /zc158/includes/modules/shipping/uspsr.php(2212): queryFactory->Execute()
#5 /zc158/includes/modules/shipping/uspsr.php(235): uspsr->adminInitializationChecks()
#6 /zc158/admin/modules.php(187): uspsr->__construct()
#7 /zc158/admin/index.php(11): require('/zc...')
--> PHP Fatal error: 1062:Duplicate entry 'uspsrUninstall' for key 'page_key' :: INSERT INTO admin_pages (page_key, language_key, main_page, page_params, menu_key, display_on_menu, sort_order) VALUES ('uspsrUninstall', 'BOX_USPSR_UNINSTALLER', 'FILENAME_USPS_UNINSTALL', '', 'tools', 'Y', 600) ==> (as called by) /zc158/includes/modules/shipping/uspsr.php on line 2212 <== in /zc158/includes/classes/db/mysql/query_factory.php on line 667.

> 
> The normal screen w/ 1.6.2 or 1.7.0:
> Attachment 21182
> 
> The abnormal screen w/ 1.8.x:
> Attachment 21183

Is this on an Encapsulated Install?
27 Feb 2026, 12:24 AM
#482
siliconbug avatar

siliconbug

Zen Follower

Join Date:
Apr 2009
Posts:
125
Plugin Contributions:
0

Re: USPS Shipping (RESTful) (USPSr)

retched:

Is this on an Encapsulated Install?

Non-encapsulated installed.

27 Feb 2026, 12:25 AM
#483
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

siliconbug:

Non-encapsulated installed.

Will make a pass at this when I'm done with the extraServices bug.

27 Feb 2026, 4:20 AM
#484
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

siliconbug:

Non-encapsulated installed.

Ready. Will be in the 1.8.3 version. To fix this now:

Open /includes/modules/shipping/uspsr.php

Around line 1608 and 2214 find:

if (!defined('MODULE_SHIPPING_USPSR_INSTALL')) {

and change to:

if (!defined('MODULE_SHIPPING_USPSR_INSTALL') && !zen_page_key_exists('uspsrUninstall')) {

Same File, go to 1612 and 2214 and find:

$db->Execute("INSERT INTO " . TABLE_ADMIN_PAGES . " (page_key, language_key, main_page, page_params, menu_key, display_on_menu, sort_order) VALUES ('uspsrUninstall', 'BOX_USPSR_UNINSTALLER', 'FILENAME_USPS_UNINSTALL', '', 'tools', 'Y', 14000)");

And change to:

$db->Execute("INSERT IGNORE INTO " . TABLE_ADMIN_PAGES . " (page_key, language_key, main_page, page_params, menu_key, display_on_menu, sort_order) VALUES ('uspsrUninstall', 'BOX_USPSR_UNINSTALLER', 'FILENAME_USPS_UNINSTALL', '', 'tools', 'Y', 14000)");
27 Feb 2026, 4:47 AM
#485
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

Small chance the line #s might be off by about 9-10. So you're looking for:

Around line 1599 and 2205 for the first edits

Around line 1603 and 2219 for the second edits

27 Feb 2026, 8:49 AM
#486
zndout avatar

zndout

New Zenner

Join Date:
Aug 2020
Location:
Pacific Northwest
Posts:
2
Plugin Contributions:
0

Re: USPS Shipping (RESTful) (USPSr)

Hey guys, really really rusty here on the basics. Just a little paranoid on uploading files/directories, soooo easy to break stuff. Many years since any tinkering...

1.5.7d PHP 7.4 Trying to get the new module going. Have the USPSr key/secret etc. Latest Plugin extracted local. From Cpanel light up the admin directory, upload renamed admin directory from plugin, that merges? not purges/kills my admin dir? Then rinse repeat with the includes dir? The one in the root, not includes within the admin dir.

Thanks in advance! Rust very bad but has not broken through the frame yet! :)

27 Feb 2026, 11:37 AM
#487
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

Zndout:

Hey guys, really really rusty here on the basics. Just a little paranoid on uploading files/directories, soooo easy to break stuff. Many years since any tinkering...

1.5.7d PHP 7.4 Trying to get the new module going. Have the USPSr key/secret etc. Latest Plugin extracted local. From Cpanel light up the admin directory, upload renamed admin directory from plugin, that merges? not purges/kills my admin dir? Then rinse repeat with the includes dir? The one in the root, not includes within the admin dir.

Thanks in advance! Rust very bad but has not broken through the frame yet! :)

So there are three directories in the ZIP file:

  • admin/
  • includes/
  • zc_plugins/

Since you're on 1.5.7, don't do anything with zc_plugins.

The admin directory, from the root of the Zip, needs to be renamed to match whatever CPanel (or you) chose as your admin. Then copy that now renamed admin directory up to matching directory of your ZenCart. The includes/ directory does NOT get renamed and goes into the matching includes/ directory.

From there, head over to your ZenCart area and visit Modules > Shipping and there should be a new row of "United States Postal Service (RESTful)". Click on that row, there should be an "Install" button for you to use.

Right now, I would hold off as there is a bug being patched up right now that crashes the admin area on install. If you're handy with a file editor, you can make the edits I suggested above.

27 Feb 2026, 4:17 PM
#488
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

Added in 1.8.3

  • Added a warning about being on the "weakest" allotment of API pulls (aka "Public Support I") in the admin backend. (You'll normally see this when you install the module or upgrade from a version pre-1.8.x.) The warning will provide the user instructions on how to upgrade tiers. ("Public Support I" generally allots 60 requests per hour. At a minimum, this module eats 2 on each request. So, in theory, you have at best 30 requests.)

  • Added the PHP Version, the ZenCart version, and installation method into the debug config report. (You would be surprised on how many people forgot to include this information on any bug reports or logs they send in.)
    **
    Fixed in 1.8.3**

  • Fixed an issue that would generate PHP warning messages when a certain extraService was returned with no "extraService" code in the API. Resolved that by assigning it a psuedo-code and gave it a selection in the admin area. (This is a temporary fix until the API inevitably changes and gives it a number.) [#120]

  • Fixed an issue that had the USPSr module try to run the DB call to install the Tools menu link to add the uninstaller twice. (Once on upgrade and once on the same initial run.) Since the "Define" wasn't properly in place, it effectively tried to go at it twice. This generated an error. Now the module will check to see if the admin page exists first (using the ZenCart function zen_page_key_exists), and if it doesn't, THEN try to install the module link. [#121]

The updated version has been submitted to the ZenCart Plugins Directory and published to the GitHub Repository.

Remember, for upgrading:

  • for traditional/manual installs, just overwrite EVERYTHING
  • for encapsulated installs, install into the VERSION directory. (Each version has its own install directory.)
27 Feb 2026, 4:23 PM
#489
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

Side note: I can't reproduce this, but I know this "issue" exists on some installs.

If you happen to generate logs for the module, and you happen to start to notice that your numbers for prices and weight appears as "0.299999999999999988897769753748434595763683319091796875" instead of 0.30. I know this is because of floating point shenanigans in PHP and some machines. What I need to know is, is the math for this being done correctly. In a future update, I will try to normalize these numbers by effectively rounding all costs to 2 decimal places, but I wanted to know if that's even necessary.

27 Feb 2026, 5:19 PM
#490
njcyx avatar

njcyx

Zen Follower

Join Date:
Apr 2019
Posts:
374
Plugin Contributions:
0

Re: USPS Shipping (RESTful) (USPSr)

retched:

I'm a little cautious about doing that as the name of the service is being used as an index for the name of the add on service. I'll go over this but I'm not sure why this is coming up on that particular version. I'm definitely going to need to see USPS debug logs because I need to see what is coming from USPS.

It doesn't work. It triggered some new warnings intermittently. Not sure why.

I will try your new version then.

27 Feb 2026, 6:20 PM
#491
siliconbug avatar

siliconbug

Zen Follower

Join Date:
Apr 2009
Posts:
125
Plugin Contributions:
0

Re: USPS Shipping (RESTful) (USPSr)

New error log on 1.8.3 w/ ZC 1.5.8.

PHP Fatal error:  Uncaught Error: Undefined constant "MODULE_SHIPPING_USPSR_WARNING_LOW_ACCESS" in /zc158/includes/modules/shipping/uspsr.php:2865
Stack trace:
#0 /zc158/includes/modules/shipping/uspsr.php(214): uspsr->getBearerToken()
#1 /zc158/includes/classes/shipping.php(91): uspsr->__construct()
#2 /zc158/includes/modules/shipping_estimator.php(148): shipping->__construct()
#3 /zc158/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php(229): require('/zc...')
#4 /zc158/includes/templates/bootstrap/common/tpl_main_page.php(233): require('/zc...')
#5 /zc158/index.php(94): require('/volume1/web/ke...')
#6 {main}
  thrown in /zc158/includes/modules/shipping/uspsr.php on line 2865

Request URI: /index.php?main_page=shopping_cart&cPath=1_41&products_id=110&sort=20a&zenid=4b8af861879b29e5225355e7f9e6560a, IP address: 72.136.107.236
--> PHP Fatal error: Uncaught Error: Undefined constant "MODULE_SHIPPING_USPSR_WARNING_LOW_ACCESS" in /zc158/includes/modules/shipping/uspsr.php:2865
Stack trace:
#0 /zc158/includes/modules/shipping/uspsr.php(214): uspsr->getBearerToken()
#1 /zc158/includes/classes/shipping.php(91): uspsr->__construct()
#2 /zc158/includes/modules/shipping_estimator.php(148): shipping->__construct()
#3 /zc158/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php(229): require('/zc...')
#4 /zc158/includes/templates/bootstrap/common/tpl_main_page.php(233): require('/zc...')
#5 /zc158/index.php(94): require('/zc...')
#6 {main}
  thrown in /zc158/includes/modules/shipping/uspsr.php on line 2865.
27 Feb 2026, 6:25 PM
#492
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

siliconbug:

New error log on 1.8.3 w/ ZC 1.5.8.

PHP Fatal error: Uncaught Error: Undefined constant "MODULE_SHIPPING_USPSR_WARNING_LOW_ACCESS" in /zc158/includes/modules/shipping/uspsr.php:2865
Stack trace:
#0 /zc158/includes/modules/shipping/uspsr.php(214): uspsr->getBearerToken()
#1 /zc158/includes/classes/shipping.php(91): uspsr->__construct()
#2 /zc158/includes/modules/shipping_estimator.php(148): shipping->__construct()
#3 /zc158/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php(229): require('/zc...')
#4 /zc158/includes/templates/bootstrap/common/tpl_main_page.php(233): require('/zc...')
#5 /zc158/index.php(94): require('/volume1/web/ke...')
#6 {main}
thrown in /zc158/includes/modules/shipping/uspsr.php on line 2865

Request URI: /index.php?main_page=shopping_cart&cPath=1_41&products_id=110&sort=20a&zenid=4b8af861879b29e5225355e7f9e6560a, IP address: 72.136.107.236
--> PHP Fatal error: Uncaught Error: Undefined constant "MODULE_SHIPPING_USPSR_WARNING_LOW_ACCESS" in /zc158/includes/modules/shipping/uspsr.php:2865
Stack trace:
#0 /zc158/includes/modules/shipping/uspsr.php(214): uspsr->getBearerToken()
#1 /zc158/includes/classes/shipping.php(91): uspsr->__construct()
#2 /zc158/includes/modules/shipping_estimator.php(148): shipping->__construct()
#3 /zc158/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php(229): require('/zc...')
#4 /zc158/includes/templates/bootstrap/common/tpl_main_page.php(233): require('/zc...')
#5 /zc158/index.php(94): require('/zc...')
#6 {main}
thrown in /zc158/includes/modules/shipping/uspsr.php on line 2865.


... That's defined though?

Is this in the front end or back end?
27 Feb 2026, 7:22 PM
#493
zndout avatar

zndout

New Zenner

Join Date:
Aug 2020
Location:
Pacific Northwest
Posts:
2
Plugin Contributions:
0

Re: USPS Shipping (RESTful) (USPSr)

retched:

So there are three directories in the ZIP file:

  • admin/
  • includes/
  • zc_plugins/

Since you're on 1.5.7, don't do anything with zc_plugins.

The admin directory, from the root of the Zip, needs to be renamed to match whatever CPanel (or you) chose as your admin. Then copy that now renamed admin directory up to matching directory of your ZenCart. The includes/ directory does NOT get renamed and goes into the matching includes/ directory.

From there, head over to your ZenCart area and visit Modules > Shipping and there should be a new row of "United States Postal Service (RESTful)". Click on that row, there should be an "Install" button for you to use.

Right now, I would hold off as there is a bug being patched up right now that crashes the admin area on install. If you're handy with a file editor, you can make the edits I suggested above.

Just installed V1.8.3 and all appears to be working correctly. Thanks to retched for all the work on this! And everyone else that has been involved. You folks are really underappreciated!

27 Feb 2026, 7:50 PM
#494
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

siliconbug:

New error log on 1.8.3 w/ ZC 1.5.8.

PHP Fatal error: Uncaught Error: Undefined constant "MODULE_SHIPPING_USPSR_WARNING_LOW_ACCESS" in /zc158/includes/modules/shipping/uspsr.php:2865
Stack trace:
#0 /zc158/includes/modules/shipping/uspsr.php(214): uspsr->getBearerToken()
#1 /zc158/includes/classes/shipping.php(91): uspsr->__construct()
#2 /zc158/includes/modules/shipping_estimator.php(148): shipping->__construct()
#3 /zc158/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php(229): require('/zc...')
#4 /zc158/includes/templates/bootstrap/common/tpl_main_page.php(233): require('/zc...')
#5 /zc158/index.php(94): require('/volume1/web/ke...')
#6 {main}
thrown in /zc158/includes/modules/shipping/uspsr.php on line 2865

Request URI: /index.php?main_page=shopping_cart&cPath=1_41&products_id=110&sort=20a&zenid=4b8af861879b29e5225355e7f9e6560a, IP address: 72.136.107.236
--> PHP Fatal error: Uncaught Error: Undefined constant "MODULE_SHIPPING_USPSR_WARNING_LOW_ACCESS" in /zc158/includes/modules/shipping/uspsr.php:2865
Stack trace:
#0 /zc158/includes/modules/shipping/uspsr.php(214): uspsr->getBearerToken()
#1 /zc158/includes/classes/shipping.php(91): uspsr->__construct()
#2 /zc158/includes/modules/shipping_estimator.php(148): shipping->__construct()
#3 /zc158/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php(229): require('/zc...')
#4 /zc158/includes/templates/bootstrap/common/tpl_main_page.php(233): require('/zc...')
#5 /zc158/index.php(94): require('/zc...')
#6 {main}
thrown in /zc158/includes/modules/shipping/uspsr.php on line 2865.



I had to REALLY work at getting this to work and by work, I mean "not work". I have a fix. But it only seems to affect "grandfathered" installs. (USPS changed the name of the API tiers... unannouncedly.) (I hate the change that removed the ability to have multiple credentials.)

Only change that needs to be changed is on line 2863:

From:
```php
if (isset($body['api_products']) && (trim((string)$body['api_products']) === '[Public Access I]') && defined('IS_ADMIN_FLAG')) {

To:

if (isset($body['api_products']) && (in_array((string)$body['api_products'], ['[Public Access]', '[Public Access I]'])) && (defined('IS_ADMIN_FLAG') && IS_ADMIN_FLAG === true)) {
28 Feb 2026, 12:54 AM
#495
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

Submitted to directory

Fixed in 1.8.4

  • Resolved an error from a bad page name being inserted into the DB that would not let people run the USPSr Uninstaller. [#126]
  • Fixed an issue that would create white page crashes on the customer side when a USPSr token would load in but the module tried to load an error message meant for the admin backend. [#124]
    ====
    Sorry about the crashes. I had to literally make a new account just to crash my test server just to get this to test.

As before:

  • Traditional/Manual: Overwrite everything from the admin directory into your admin directory. Overwrite everything from the root/includes directory into the includes directory of the root of your ZenCart.
  • Encapsulated: Upload the zc_plugins directory from the root of the ZIP to the root of your admin. (Nothing should be overwritten as it is a new directory.) Visit the Plugins Manager and upgrade from there.

Unless an emergency happens, no update will be released earlier than 30 days or if something on the API breaks.

2 Mar 2026, 3:27 PM
#496
njcyx avatar

njcyx

Zen Follower

Join Date:
Apr 2019
Posts:
374
Plugin Contributions:
0

Re: USPS Shipping (RESTful) (USPSr)

Here is a feedback. I contacted USPS last Friday to submit a request to upgrade my API call limit. Here is the email I received from USPS. I'm not sure "API Product Requested", I assume the same "Public Access" service but more api calls. We don't need "Shipping Suite" for this plug-in, right?

==

The default product includes OAuth, Addresses, Service Standards, International Pricing, Domestic Pricing, Shipping Options, Locations, Tracking and UserInfo.

The different API products are Public Access and Shipping Suite.

Public Access includes OAuth, Address, Service Standards, Domestic Prices, International Prices, Shipping Options, Locations, Tracking
Shipping Suite includes Public Access, + Labels, +Payments, +Carrier Pickup, +SCAN Form, +Containers

The entire API Catalog & Documentation can be found on the Developers Portal here: https://developers.usps.com/apis

Please provide the following information along with the API Product you would like.

Your Name:
Company Name:
Company Address:
Company Contact Phone #:
API Product Requested:
USPS.com Business (or BCG) Username:
Legacy or WebTools UserId (if unknown put n/a)
Developers Portal App Name:
Consumer Key (Client ID):
What product is listed in your App?
Approximate API calls per day?
Customer Registration ID (CRID):
Mailer ID (MID):
What is your USPS Contract number if you have one (otherwise N/A)?
(Required for Shipping Suite) Enterprise Payment Account (EPS) #:
What software or plugin are you using to access the APIs (or a homegrown solution)?

2 Mar 2026, 3:37 PM
#497
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

njcyx:

Here is a feedback. I contacted USPS last Friday to submit a request to upgrade my API call limit. Here is the email I received from USPS. I'm not sure "API Product Requested", I assume the same "Public Access" service but more api calls. We don't need "Shipping Suite" for this plug-in, right?

==

The default product includes OAuth, Addresses, Service Standards, International Pricing, Domestic Pricing, Shipping Options, Locations, Tracking and UserInfo.

The different API products are Public Access and Shipping Suite.

Public Access includes OAuth, Address, Service Standards, Domestic Prices, International Prices, Shipping Options, Locations, Tracking
Shipping Suite includes Public Access, + Labels, +Payments, +Carrier Pickup, +SCAN Form, +Containers

The entire API Catalog & Documentation can be found on the Developers Portal here: https://developers.usps.com/apis

Please provide the following information along with the API Product you would like.

Your Name:
Company Name:
Company Address:
Company Contact Phone #:
API Product Requested:
USPS.com Business (or BCG) Username:
Legacy or WebTools UserId (if unknown put n/a)
Developers Portal App Name:
Consumer Key (Client ID):
What product is listed in your App?
Approximate API calls per day?
Customer Registration ID (CRID):
Mailer ID (MID):
What is your USPS Contract number if you have one (otherwise N/A)?
(Required for Shipping Suite) Enterprise Payment Account (EPS) #:
What software or plugin are you using to access the APIs (or a homegrown solution)?

Yes, **Public Access **is what is needed for this module only. Shipping Suite is if you're also trying to use the API to pay for labels, make labels, create SCAN forms, and schedule pickups through the API. None of which is particularly available through THIS module. (Someone might want to make a module like this later... but it is not me.) The only API Access that you need is everything in "Public Access". In particular, Domestic Prices, International Prices, Service Standards, and OAuth (of course). So, when they ask for API Product, request "Public Access". To get the CRID and MID, you will need to get to the cop.usps.com site and navigate as instructed on the wiki.

I'll take this and update the wiki entry as well later today. Additionally, if someone is handy and can tell me their old "Public Access I" API key can work with International Service Standards, I have a bit of code to write to update shipping estimates.

2 Mar 2026, 4:03 PM
#498
njcyx avatar

njcyx

Zen Follower

Join Date:
Apr 2019
Posts:
374
Plugin Contributions:
0

Re: USPS Shipping (RESTful) (USPSr)

Thanks for your always help. I will let my USPS agent know this. Yes, I followed your wiki guide to apply for the CRID, MID and EPS already.

For EPS application, you don't have to provide your bank account for ACH payment. There is another option for the credit card.

2 Mar 2026, 7:56 PM
#499
njcyx avatar

njcyx

Zen Follower

Join Date:
Apr 2019
Posts:
374
Plugin Contributions:
0

Re: USPS Shipping (RESTful) (USPSr)

Another update. I just received a follow-up email from USPS. The USPS agent said "We recently expanded the daily API limit to 20,000 per day for Public Access. You should be all set." I'm currently on "Public Access I" plan.

2 Mar 2026, 8:14 PM
#500
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

njcyx:

Another update. I just received a follow-up email from USPS. The USPS agent said "We recently expanded the daily API limit to 20,000 per day for Public Access. You should be all set." I'm currently on "Public Access I" plan.

Oh ok. I'm that case, I'll clear the warning out next round of edits.

Thanks for the updates.

I also wonder if that applies to my Public access V tier. Whelp. I'll find out one way or the other.