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

USPS Shipping (RESTful) (USPSr)

Sticky

Views: 54,964

Results 281 to 300 of 558
17 Oct 2025, 8:56 PM
#281
retched avatar

retched

Totally Zenned

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

USPS Shipping (RESTful) (USPSr)

swguy:

Look at the query. It still uses $_POST['state']. Perhaps change to $selectedState or add null coalesce.

Jesus, shocked I didn't catch that.

Changed.

17 Oct 2025, 8:58 PM
#282
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,720
Plugin Contributions:
56

Re: USPS Shipping (RESTful) (USPSr)

It's extremely hard to read your own code. It's like proofreading your own writing.

Thanks for knocking out these little issues. So happy we have a USPS module ready for the changes coming in the New Year!

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

17 Oct 2025, 9:17 PM
#283
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,848
Plugin Contributions:
17

Re: USPS Shipping (RESTful) (USPSr)

For those using 1.4.0 encapsulated on 1.5.7d, should they upgrade to 1.5.0 or wait for a release of these current changes?

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

17 Oct 2025, 9:20 PM
#284
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)

dbltoe:

For those using 1.4.0 encapsulated on 1.5.7d, should they upgrade to 1.5.0 or wait for a release of these current changes?

You should definitely get to 1.5.0 as soon as you can. 1.5.1 (version # for now) has more or less minor bug fixes. Still essential, but unless you're using your cart on the fringiest of fring scenarios, you can wait for the official 1.5.1 to drop.

BTW, I'm still trying to figure out the weird "can't save" loop you get in for encapsulated installs.

18 Oct 2025, 12:12 PM
#285
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 v1.5.1 to the Plugins Directory.

Not much changed here besides the following:


Added in 1.5.1

  • Added a parameter to the notifier NOTIFY_SHIPPING_USPS_BEFORE_GETQUOTE to handle the dimmensions of the package. This allows modules to cut in and modify the number of boxes and the average package size sent as part of the cart quote request. (Shipping Boxes Manager can now use this notifier. I'm not hard-coding in the older code from USPS WebTools.)

Changed in 1.5.1

  • Dropped the override machineability flag, internally. Instead, the module will retrieve the appropriate quote as requested. (Leave it up to the shop owner to figure out if it's machineable or not.) Does not affect "NONSTANDARD". (In other words, this does not remove any field but instead of having the module do the work in selecting the machineability status, the module will just pull up the matching rate from the configuration.)

Fixed in 1.5.1

  • Fixed the admin area functions file to search out for the catalog area functions file and include that one instead of duplicating it. (Continuing the change from 1.5.0.)
  • Fixed an issue that would generate a PHP warning when errors are generated and a key was not found. [#83]

Download has been submitted to the module directory,

Also available on the GitHub:
https://github.com/retched/ZC-USPSRestful/releases/tag/v1.5.1

18 Oct 2025, 3:39 PM
#286
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,848
Plugin Contributions:
17

Re: USPS Shipping (RESTful) (USPSr)

1.5.7d, PHP 7.4.33. Clicking on Upgrade Available, then Upgrade (with v1.5.1 shown as selected) has> Warning: blah blah

Clicking on Upgrade shows no issues in Console, a partial blank page, and no log file is created.

Refreshing the page has no effect.

Going back to Modules >> Plugin Manager results in the Plugin Manager page with USPSR still showing v1.4.0.

Clicking on info shows Version Installed: v1.4.0 and the Upgrade Available button.

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

18 Oct 2025, 8:39 PM
#287
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)

dbltoe:

1.5.7d, PHP 7.4.33. Clicking on Upgrade Available, then Upgrade (with v1.5.1 shown as selected) has

Clicking on Upgrade shows no issues in Console, a partial blank page, and no log file is created.

Refreshing the page has no effect.

Going back to Modules >> Plugin Manager results in the Plugin Manager page with USPSR still showing v1.4.0.

Clicking on info shows Version Installed: v1.4.0 and the Upgrade Available button.

Investigating will post up tonight

19 Oct 2025, 6:17 AM
#288
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)

dbltoe:

1.5.7d, PHP 7.4.33. Clicking on Upgrade Available, then Upgrade (with v1.5.1 shown as selected) has

Clicking on Upgrade shows no issues in Console, a partial blank page, and no log file is created.

Refreshing the page has no effect.

Going back to Modules >> Plugin Manager results in the Plugin Manager page with USPSR still showing v1.4.0.

Clicking on info shows Version Installed: v1.4.0 and the Upgrade Available button.

I'm not able to reproduce this on 1.5.7d.

Took a fresh install and installed 1.4.0 of the module. From there, I went to 1.5.1 via the usual method (overwriting everything). And the module installed OK and upgraded as such. Are you sure a log was not generated at all?

19 Oct 2025, 10:06 AM
#289
siliconbug avatar

siliconbug

Zen Follower

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

Re: USPS Shipping (RESTful) (USPSr)

Non-encapsulated w/ ZC v1.5.8

International Rates don't show up in v1.5.1 (no error logs generated).

19 Oct 2025, 10:18 AM
#290
siliconbug avatar

siliconbug

Zen Follower

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

Re: USPS Shipping (RESTful) (USPSr)

Update to my earlier post:
I've enabled International Rates in the admin panel, but they aren't appearing on the storefront when a customer selects a shipping destination outside the U.S.

19 Oct 2025, 12:04 PM
#291
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:

Update to my earlier post:
I've enabled International Rates in the admin panel, but they aren't appearing on the storefront when a customer selects a shipping destination outside the U.S.

Do you have a USPS log to show? Need the request part to see what's going on.

19 Oct 2025, 1:36 PM
#292
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 w/ ZC v1.5.8

International Rates don't show up in v1.5.1 (no error logs generated).

Found the bug. You're probably running into this:

[19-Oct-2025 09:11:41 America/New_York] Request URI: /zencart210/index.php?main_page=popup_shipping_estimator, IP address: 127.0.0.1, Language id 1
#0 E:\xampp\htdocs\zencart210\zc_plugins\USPSRestful\v0.0.0\catalog\includes\modules\shipping\uspsr.php(2297): zen_debug_error_handler()
#1 E:\xampp\htdocs\zencart210\zc_plugins\USPSRestful\v0.0.0\catalog\includes\modules\shipping\uspsr.php(398): uspsr->_getQuote()
#2 E:\xampp\htdocs\zencart210\includes\classes\shipping.php(257): uspsr->quote()
#3 E:\xampp\htdocs\zencart210\includes\modules\shipping_estimator.php(163): shipping->quote()
#4 E:\xampp\htdocs\zencart210\includes\templates\template_default\popup_shipping_estimator\tpl_main_page.php(15): require('E:\\xampp\\htdocs...')
#5 E:\xampp\htdocs\zencart210\index.php(94): require('E:\\xampp\\htdocs...')
--> PHP Warning: Undefined variable $pkg_intl_length in E:\xampp\htdocs\zencart210\zc_plugins\USPSRestful\v0.0.0\catalog\includes\modules\shipping\uspsr.php on line 2297.

Which is causing something like this to be sent out:

{
    "weight": 0.8125,
    "length": null,
    "height": null,
    "thickness": null,
    "processingCategory": "LETTERS",
    "nonMachinableIndicators": {
        "isPolybagged": false,
        "hasClosureDevices": false,
        "hasLooseItems": false,
        "isRigid": false,
        "isSelfMailer": false,
        "isBooklet": false
    },
    "itemValue": 47.4,
    "destinationCountryCode": "CA"
}

Needless to say, this fails. Working on a x.x.2 patch now.

There was also another "bug" sort of regarding First Class Mail Letters but it's more of a rounding error that occurs. Incoming update shortly.

19 Oct 2025, 2:41 PM
#293
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)

This update was submitted to the plugin directory.

In short, I forgot when I deleted the variables that contained the measurement and changed them to a pre-calculated property of the class, I forgot to also change them for international shipments. Additionally, while doing the tests for First Class Mail International, I saw that I was setting the limit too low. I learned that the API will automatically rate international letters that are bigger than 3.5 ounces to use the "flats" (or large envelopes) rates instead of outright rejecting them. I changed the value for future installs but for existing installs that value will not be changed. If you use pounds as your standard and you want to use First Class Mail International Letter, change the value from 0.21875 to 0.999625. If you use kilograms as your standard and you want to use First Class Mail International Letter, change the value from 0.0992233 to 0.4534228 instead. This should resolve that issue.

If you're capable enough with modifying PHP code and want to see exactly what change to perform, you can view the diff of /includes/modules/shipping/uspsr.php. While waiting, you can get the newest version from the Git repo.

As always, thanks for your patience.

19 Oct 2025, 6:27 PM
#294
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)

retched:

This update was submitted to the plugin directory.

In short, I forgot when I deleted the variables that contained the measurement and changed them to a pre-calculated property of the class, I forgot to also change them for international shipments. Additionally, while doing the tests for First Class Mail International, I saw that I was setting the limit too low. I learned that the API will automatically rate international letters that are bigger than 3.5 ounces to use the "flats" (or large envelopes) rates instead of outright rejecting them. I changed the value for future installs but for existing installs that value will not be changed. If you use pounds as your standard and you want to use First Class Mail International Letter, change the value from 0.21875 to 0.999625. If you use kilograms as your standard and you want to use First Class Mail International Letter, change the value from 0.0992233 to 0.4534228 instead. This should resolve that issue.

If you're capable enough with modifying PHP code and want to see exactly what change to perform, you can view the diff of /includes/modules/shipping/uspsr.php. While waiting, you can get the newest version from the Git repo.

As always, thanks for your patience.

This module is now published on ZenCart's Plugin Directory

10 Nov 2025, 5:07 PM
#295
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,720
Plugin Contributions:
56

Re: USPS Shipping (RESTful) (USPSr)

Started getting "Unable to obtain bearer token." in admin using 1.5.2. Storefront not showing rates at all. Even created new credentials to see if that would help, but no dice.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

10 Nov 2025, 7:14 PM
#296
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)

swguy:

Started getting "Unable to obtain bearer token." in admin using 1.5.2. Storefront not showing rates at all. Even created new credentials to see if that would help, but no dice.

Something likely changed on the USPS side. I'll look into this with the next few hours.

10 Nov 2025, 7:22 PM
#297
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)

swguy:

Started getting "Unable to obtain bearer token." in admin using 1.5.2. Storefront not showing rates at all. Even created new credentials to see if that would help, but no dice.

Any chance a log was made available about either one? Trying to see if an error code was generated.

10 Nov 2025, 11:52 PM
#298
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,720
Plugin Contributions:
56

Re: USPS Shipping (RESTful) (USPSr)

One small issue: you have to null coalesce $error_letter['code'] on line 436 of includes/modules/shipping/uspsr.php

                'code' => $error_letter['code'] ?? '',

also for loop above it.

        foreach (($_letter['error']['errors'] ?? []) as $error_letter) {

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

11 Nov 2025, 12:00 AM
#299
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,720
Plugin Contributions:
56

Re: USPS Shipping (RESTful) (USPSr)

We keep getting this:

RAW JSON FROM USPS:

{
"apiVersion": "/prices/v3",
"error": {
"code": "429",
"message": "Exceeded quota limit. Please contact [email protected] and a representative will assist.",
"errors": [
{
"title": "Exceeded quota limit. Please contact [email protected] and a representative will assist.",
"detail": ""
}
]
}
}

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

11 Nov 2025, 12:55 AM
#300
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)

swguy:

We keep getting this:

RAW JSON FROM USPS:

{
"apiVersion": "/prices/v3",
"error": {
"code": "429",
"message": "Exceeded quota limit. Please contact [email protected] and a representative will assist.",
"errors": [
{
"title": "Exceeded quota limit. Please contact [email protected] and a representative will assist.",
"detail": ""
}
]
}
}

Yup.was afraid of that. That's the same quota issue that comes up because they only give you 60(?) lookups per hour. You might need to write in to the API team and ask for a larger quota.

As for the null coalesce you mentioned earlier I'll look into it.