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

USPS Shipping (RESTful) (USPSr)

Sticky

Views: 54,961

Results 41 to 60 of 558
5 Mar 2025, 12:58 PM
#41
dbltoe avatar

dbltoe

Totally Zenned

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

USPS Shipping (RESTful) (USPSr)

I don't know if you are using the latest zip from GitHub for 2.#.0, but that's what I am testing with. As stated, all installed items are latest from GitHub.

I turned restful back on and enabled the errors and log (BTW, I think you meant to say, "CAUTION: Each log file is at least 300KB big." versus "CAUTION: Each long file is at least 300KB big."

I added an item to the cart, went to the shopping cart, and used the estimator. I received the correct quote and no errors were shown or logged.

I then clicked on Checkout and selected Guest Checkout (OPC). I got the standard screen with no shipping or payment options. They should not show until Contact and Billing are set.

I set the Contact and Billing using the simple 5-digit Zip. Upon setting them, I see Shipping options with the Priority pre-selected. While it did list the options in the selected "Price-LowtoHigh", it might be best to also pre-select the lowest option.

At this point, there are still no errors shown or logs generated. As a test, I went back to billing and entered what my browser had stored, which was a Zip + 4 code. That resulted in a 500 error and and log files.

Since the session had the info locked in to Guest, I went back to the cart and tried Zip + 4 with the estimator and got basically the same error but a partial blank screen.

I tried the zip with no hyphen and got the same results.

My assumption (I know) is that anything other than the 5-digit zip fails. Using just a 5 digit zip works fine.

The USPS K11I accepts Zip + 4

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

5 Mar 2025, 2:27 PM
#42
jodean avatar

jodean

Totally Zenned

Join Date:
May 2011
Location:
Tennessee
Posts:
511
Plugin Contributions:
0

Re: USPS Shipping (RESTful) (USPSr)

dbltoe:

I don't know if you are using the latest zip from GitHub for 2.#.0, but that's what I am testing with. As stated, all installed items are latest from GitHub.

I turned restful back on and enabled the errors and log (BTW, I think you meant to say, "CAUTION: Each log file is at least 300KB big." versus "CAUTION: Each long file is at least 300KB big."

I added an item to the cart, went to the shopping cart, and used the estimator. I received the correct quote and no errors were shown or logged.

I then clicked on Checkout and selected Guest Checkout (OPC). I got the standard screen with no shipping or payment options. They should not show until Contact and Billing are set.

I set the Contact and Billing using the simple 5-digit Zip. Upon setting them, I see Shipping options with the Priority pre-selected. While it did list the options in the selected "Price-LowtoHigh", it might be best to also pre-select the lowest option.

At this point, there are still no errors shown or logs generated. As a test, I went back to billing and entered what my browser had stored, which was a Zip + 4 code. That resulted in a 500 error and and log files.

Since the session had the info locked in to Guest, I went back to the cart and tried Zip + 4 with the estimator and got basically the same error but a partial blank screen.

I tried the zip with no hyphen and got the same results.

My assumption (I know) is that anything other than the 5-digit zip fails. Using just a 5 digit zip works fine.

The USPS K11I accepts Zip + 4

I finally found the current version and it is working now.

5 Mar 2025, 3:51 PM
#43
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)

Have you tried it with Zip + 4 or just a nine-digit zip code?

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

5 Mar 2025, 4:05 PM
#44
jodean avatar

jodean

Totally Zenned

Join Date:
May 2011
Location:
Tennessee
Posts:
511
Plugin Contributions:
0

Re: USPS Shipping (RESTful) (USPSr)

dbltoe:

Have you tried it with Zip + 4 or just a nine-digit zip code?

Just the basic four or nine.

5 Mar 2025, 4:05 PM
#45
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:

I don't know if you are using the latest zip from GitHub for 2.#.0, but that's what I am testing with. As stated, all installed items are latest from GitHub.

I turned restful back on and enabled the errors and log (BTW, I think you meant to say, "CAUTION: Each log file is at least 300KB big." versus "CAUTION: Each long file is at least 300KB big."

I'm 95% sure that was a carryover when I was still generating large files. I'll start changing it around for the next version.

dbltoe:

I added an item to the cart, went to the shopping cart, and used the estimator. I received the correct quote and no errors were shown or logged.

I then clicked on Checkout and selected Guest Checkout (OPC). I got the standard screen with no shipping or payment options. They should not show until Contact and Billing are set.

How exactly are you getting that to happen here?

dbltoe:

I set the Contact and Billing using the simple 5-digit Zip. Upon setting them, I see Shipping options with the Priority pre-selected. While it did list the options in the selected "Price-LowtoHigh", it might be best to also pre-select the lowest option.

I have absolutely no idea why the last option presented is selected last. I'll start looking into what's going on and how to select the cheaper option.

dbltoe:

At this point, there are still no errors shown or logs generated. As a test, I went back to billing and entered what my browser had stored, which was a Zip + 4 code. That resulted in a 500 error and and log files.

Since the session had the info locked in to Guest, I went back to the cart and tried Zip + 4 with the estimator and got basically the same error but a partial blank screen.

I tried the zip with no hyphen and got the same results.

My assumption (I know) is that anything other than the 5-digit zip fails. Using just a 5 digit zip works fine.

The USPS K11I accepts Zip + 4

Okay I got the same the result. Looking at the API error message that is generated, entering 9 digits straight with no hyphen is actually causing the API to fail to validate because it's looking for the proper format of (in regEx) ^\d{5}(?:[-\s]\d{4})?$\

Which means it's looking for the ZipCode to be a string that starts with 5 digits has a hyphen (or a space) and ends with 4. If you enter nine digits straight in, it fails because it's not a recognized format for the API. Nonetheless... I SHOULD be able to get something going with this. (That is, take the input and make it the proper format for the API.)

5 Mar 2025, 4:15 PM
#46
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)

For demonstration, this is what happens when I run the API return through a regex tester:

6 Mar 2025, 3:10 AM
#47
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)

That test might work, but, if you use a Zip + 4 in the shipping estimator on the shopping cart page, you get a partial blank screen.

[06-Mar-2025 03:05:38 UTC] PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /zc_plugins/USPSRestful/v0.0.0/catalog/includes/modules/shipping/uspsr.php:916
Stack trace:
#0 /includes/classes/shipping.php(257): uspsr->quote('')
#1 /includes/modules/shipping_estimator.php(163): shipping->quote()
#2 /includes/templates/jetmar_boot/templates/tpl_shopping_cart_default.php(240): require('/home/enigjohn/...')
#3 /includes/templates/jetmar_boot/common/tpl_main_page.php(233): require('/home/enigjohn/...')
#4 /index.php(94): require('/home/enigjohn/...')
#5 {main}
thrown in /zc_plugins/USPSRestful/v0.0.0/catalog/includes/modules/shipping/uspsr.php on line 916

[06-Mar-2025 03:05:38 UTC] Request URI: /index.php?main_page=shopping_cart, IP address: 216.177.186.199
--> PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /zc_plugins/USPSRestful/v0.0.0/catalog/includes/modules/shipping/uspsr.php:916
Stack trace:
#0 /includes/classes/shipping.php(257): uspsr->quote('')
#1 /includes/modules/shipping_estimator.php(163): shipping->quote()
#2 /includes/templates/jetmar_boot/templates/tpl_shopping_cart_default.php(240): require('/home/enigjohn/...')
#3 /includes/templates/jetmar_boot/common/tpl_main_page.php(233): require('/home/enigjohn/...')
#4 /index.php(94): require('/home/enigjohn/...')
#5 {main}
thrown in /zc_plugins/USPSRestful/v0.0.0/catalog/includes/modules/shipping/uspsr.php on line 916.

[06-Mar-2025 03:05:38 UTC] Request URI: /index.php?main_page=shopping_cart, IP address: 216.177.186.199
--> PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /zc_plugins/USPSRestful/v0.0.0/catalog/includes/modules/shipping/uspsr.php:916
Stack trace:
#0 /includes/classes/shipping.php(257): uspsr->quote('')
#1 /includes/modules/shipping_estimator.php(163): shipping->quote()
#2 /includes/templates/jetmar_boot/templates/tpl_shopping_cart_default.php(240): require('/home/enigjohn/...')
#3 /includes/templates/jetmar_boot/common/tpl_main_page.php(233): require('/home/enigjohn/...')
#4 /index.php(94): require('/home/enigjohn/...')
#5 {main}
thrown in /zc_plugins/USPSRestful/v0.0.0/catalog/includes/modules/shipping/uspsr.php on line 916.

And the USPS log says the token was revoked.

Again, all works fine for a five-digit zip.

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

6 Mar 2025, 4:42 AM
#48
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:

That test might work, but, if you use a Zip + 4 in the shipping estimator on the shopping cart page, you get a partial blank screen.

[06-Mar-2025 03:05:38 UTC] PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /zc_plugins/USPSRestful/v0.0.0/catalog/includes/modules/shipping/uspsr.php:916
Stack trace:
#0 /includes/classes/shipping.php(257): uspsr->quote('')
#1 /includes/modules/shipping_estimator.php(163): shipping->quote()
#2 /includes/templates/jetmar_boot/templates/tpl_shopping_cart_default.php(240): require('/home/enigjohn/...')
#3 /includes/templates/jetmar_boot/common/tpl_main_page.php(233): require('/home/enigjohn/...')
#4 /index.php(94): require('/home/enigjohn/...')
#5 {main}
thrown in /zc_plugins/USPSRestful/v0.0.0/catalog/includes/modules/shipping/uspsr.php on line 916

[06-Mar-2025 03:05:38 UTC] Request URI: /index.php?main_page=shopping_cart, IP address: 216.177.186.199
--> PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /zc_plugins/USPSRestful/v0.0.0/catalog/includes/modules/shipping/uspsr.php:916
Stack trace:
#0 /includes/classes/shipping.php(257): uspsr->quote('')
#1 /includes/modules/shipping_estimator.php(163): shipping->quote()
#2 /includes/templates/jetmar_boot/templates/tpl_shopping_cart_default.php(240): require('/home/enigjohn/...')
#3 /includes/templates/jetmar_boot/common/tpl_main_page.php(233): require('/home/enigjohn/...')
#4 /index.php(94): require('/home/enigjohn/...')
#5 {main}
thrown in /zc_plugins/USPSRestful/v0.0.0/catalog/includes/modules/shipping/uspsr.php on line 916.

[06-Mar-2025 03:05:38 UTC] Request URI: /index.php?main_page=shopping_cart, IP address: 216.177.186.199
--> PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /zc_plugins/USPSRestful/v0.0.0/catalog/includes/modules/shipping/uspsr.php:916
Stack trace:
#0 /includes/classes/shipping.php(257): uspsr->quote('')
#1 /includes/modules/shipping_estimator.php(163): shipping->quote()
#2 /includes/templates/jetmar_boot/templates/tpl_shopping_cart_default.php(240): require('/home/enigjohn/...')
#3 /includes/templates/jetmar_boot/common/tpl_main_page.php(233): require('/home/enigjohn/...')
#4 /index.php(94): require('/home/enigjohn/...')
#5 {main}
thrown in /zc_plugins/USPSRestful/v0.0.0/catalog/includes/modules/shipping/uspsr.php on line 916.

> 
> And the USPS log says the token was revoked.
> 
> Again, all works fine for a five-digit zip.

Can you see if you also get a USPSr log so I can compare? For some reason I can't get a white screen on my loadout. Not sure if it's because I'm running 2.1.0
6 Mar 2025, 10:10 AM
#49
swguy avatar

swguy

Administrator

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

Re: USPS Shipping (RESTful) (USPSr)

Have you installed the latest released USPS-r? I thought this was fixed.

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.

6 Mar 2025, 4:45 PM
#50
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)

As stated, all items installed are latest GitHub versions.

PM with log sent.

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

6 Mar 2025, 5:11 PM
#51
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:

As stated, all items installed are latest GitHub versions.

PM with log sent.

Hi your PMs are being blocked as I tried to send it. You can link a private pastebin or send to my hotmail.com (yes I'm old) email address with the same username.

6 Mar 2025, 5:50 PM
#52
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:

Have you installed the latest released USPS-r? I thought this was fixed.

I'm 90% sure I know what the problem is and it's something that I didn't think WOULD be a problem.

6 Mar 2025, 11:02 PM
#53
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)

Using the estimator on the shopping cart.

Estimate time to No in Restful

Zip + 4 used.

I get the expected two options with the cheapest highlighted.

Continuing to OPC using Zip + 4

after adding data for guest, I am presented with the two shipping options with the more expensive priority selected.
The order processed and returned with the Zip + 4 and (NEW) the fee charged was for the cheaper ground although priority was checked on the confirmation page.

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

6 Mar 2025, 11:16 PM
#54
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:

Using the estimator on the shopping cart.

Estimate time to No in Restful

Zip + 4 used.

I get the expected two options with the cheapest highlighted.

Okay I thought so. For clarity: dbltoe sent me their log and as part of the log I noticed the "standards" request was being bounced and causing errors.

For some reason, the USPS thought it was OK to allow the ZipCode to be hyphenated in cost quotes request but NOT be hyphenated in the "standards" (aka time estimates) request. This is weird and something I have no control over as it's on the USPS' side as to how the API request is handled. I'm going to have the module chop off the back four and use only the front five digits of the Zip code quote making or time estimates.

dbltoe:

Continuing to OPC using Zip + 4

after adding data for guest, I am presented with the two shipping options with the more expensive priority selected.

I still do not know WHY the more expensive option is being selected by default. I've tested this on my own test box, and if I remove all other shipping methods besides USPS, it defaults to the most expensive USPS option. I do not know why that is.

dbltoe:

The order processed and returned with the Zip + 4 and (NEW) the fee charged was for the cheaper ground although priority was checked on the confirmation page.

And now I need to start investigating why the wrong option was used during OPC checkout. (I'm 90% sure it has to do with the "value" attribute of the radio button.) Trying to fix both of these now.

7 Mar 2025, 4:59 AM
#55
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)

Tl;dr: I figured out what went wrong with, everything here. A bugfix will be submitted shortly.

retched:

Okay I thought so. For clarity: dbltoe sent me their log and as part of the log I noticed the "standards" request was being bounced and causing errors.

For some reason, the USPS thought it was OK to allow the ZipCode to be hyphenated in cost quotes request but NOT be hyphenated in the "standards" (aka time estimates) request. This is weird and something I have no control over as it's on the USPS' side as to how the API request is handled. I'm going to have the module chop off the back four and use only the front five digits of the Zip code quote making or time estimates.

Really annoying bug or limitation of the API. It accepts 00000-1234 for quotes but will break when it tries to make standards quote requests (aka how many days does this method take) which must be either 000001234 or 00000. The fix is to nix the Plus 4 from the submission and instead basing it solely on the Zip Code (the five digits). Nobody has to change anything, the zipcode will be dispatched as five digits. (AKA if your customer puts in 00000-1234, the order will process as 00000 but will be inserted into the order as 00000-1234.)

retched:

I still do not know WHY the more expensive option is being selected by default. I've tested this on my own test box, and if I remove all other shipping methods besides USPS, it defaults to the most expensive USPS option. I do not know why that is.

And now I need to start investigating why the wrong option was used during OPC checkout. (I'm 90% sure it has to do with the "value" attribute of the radio button.) Trying to fix both of these now.

I know why. I thought I was being smart trying to not "waste" indices of a loop and only counting what was used. This was bad. OPC and ZenCart's shipping estimator used those ID's and it backfired as it considered ALL of the methods the "cheapest" as they all were sent out as "usps_usps0". Moved the logic of the index count to a more sensible location.

Each of these fixes are ready to be deployed in version v1.1.1. Which will be published shortly. Just waiting to make sure that no other problems arise. (My apologies, this is possibly the biggest contribution I've done to date.)

7 Mar 2025, 6:20 PM
#56
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)

Pending updates v1.1.1 has been submitted to the Module Directory and published to the GitHub.

https://github.com/retched/ZC-USPSRestful/releases/tag/v1.1.1

What's changed?
****
Fixed

  • Resolved all issues with regards to the selection of shipping methods during checkout. (Issues #28, #29, #30, #31) (Long and short run, there was a problem with the counting of each module presented and it caused issues.)
  • Fixed an issue that came up when trying to squash options but you were also using estimated dates/times (the squashing was ignored and all options were presented anyway, bad regex matching). (Issue #32)
7 Mar 2025, 6:34 PM
#57
swguy avatar

swguy

Administrator

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

Re: USPS Shipping (RESTful) (USPSr)

This looks like something you are already investigating, just passing on a simpler report. Select more than one method in USPS-r's admin configuration. Go to standard checkout and you see one radio button per method. However, all have the value of ship-uspsr-usps0 as noted. I thought it would be a simple matter of only initializing the counter ($m) at the start of the outer loop, but it still selected the first method (the most expensive) on the payment page, no matter which I selected on the shipping page.

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.

7 Mar 2025, 6:43 PM
#58
swguy avatar

swguy

Administrator

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

Re: USPS Shipping (RESTful) (USPSr)

Just downloaded 1.1.1. I think you still have an indexing issue. It still always shows the first method (Priority Mail) as the selected one on the second page of checkout.

Also you might want to think about how you handle the checkout pages after initial selection. You'll notice the other shipping modules use the signature

function quote($method = '')

where the selected method is passed in after the first call.

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.

7 Mar 2025, 7:32 PM
#59
swguy avatar

swguy

Administrator

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

Re: USPS Shipping (RESTful) (USPSr)

If this helps, the quote method is called with an argument -see includes/classes/shipping.php line 257

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.

7 Mar 2025, 8:47 PM
#60
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:

This looks like something you are already investigating, just passing on a simpler report. Select more than one method in USPS-r's admin configuration. Go to standard checkout and you see one radio button per method. However, all have the value of ship-uspsr-usps0 as noted. I thought it would be a simple matter of only initializing the counter ($m) at the start of the outer loop, but it still selected the first method (the most expensive) on the payment page, no matter which I selected on the shipping page.

Ugh I thought I tackled this. It's showing up as working on my end... Unless I packed the wrong files which is strongly possible...