-
USPS Shipping (RESTful) (USPSr)
USPS Shipping (RESTful) for Zen Cart
This module provides sellers a chance to offer United States Postal Service (USPS) shipping rates to customers during checkout. This is done by pulling the rates directly from the USPS' REST API.
This module supports versions 1.5.8 onward innately. (Support from 1.5.7 and backward is not necessarily guaranteed but is plausible. Read the Installation steps below for more details.) This script was primarily written with PHP8 in mind. (It might have problems working with PHP7.)
There isn't much difference between the two versions. However, if you managed to get the WebTools version to work, CONTINUE TO USE THAT VERSION.
USPS API Documentation: https://developers.usps.com/apis
This API takes advantage of four API's: Domestic Prices 3.0, International Prices 3.0, Service Standards 3.0, and OAuth 3.0.
ZenCart Plugins Download: https://www.zen-cart.com/downloads.php?do=file&id=2395 (Pending) (or use the Releases function on the GitHub repository)
GitHub Repository: https://github.com/retched/ZC-USPSRestful
** This thread is only for the USPSr version of the USPS module. For assistance with the original USPS module which uses the WebTools API, you should post in its megathread: https://www.zen-cart.com/showthread....Support-Thread
-
Re: USPS Shipping (RESTful) (USPSr)
i tried to install in zen210 through plugin module and it error on shipping modules say if you were adding data press the back button and shipping modules stop showing after last 1. same thing happens with the web tools version also.
no error log is produced.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
jimmie
i tried to install in zen210 through plugin module and it error on shipping modules say if you were adding data press the back button and shipping modules stop showing after last 1. same thing happens with the web tools version also.
no error log is produced.
This sounds like a cookie issue. What do you mean by "error on shipping modules"? Also be sure that if you have the problem on WebTools, you make a post on the WebTools version as well.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
retched
This sounds like a cookie issue. What do you mean by "error on shipping modules"? Also be sure that if you have the problem on WebTools, you make a post on the WebTools version as well.
when i go to shipping modules message at the top says to refresh page
when looking at modules all the other shipping modules configuration settings are missing
-
Re: USPS Shipping (RESTful) (USPSr)
Are you sure there are no error logs generated? What other modules/add ons do you have? What browser add-ons do you have?
-
Re: USPS Shipping (RESTful) (USPSr)
Found the problem:
[ALTER TABLE orders MODIFY shipping_method varchar(255) NOT NULL DEFAULT '']
This happens when the module is enabled seems something changed it to TEXT and both my module and the WebTools module tries to revert it back to VARCHAR(255). I'm going to modify my module to check to see if the column is either 255 or TEXT.
-
Re: USPS Shipping (RESTful) (USPSr)
Incoming Changes for Version 0.2.0
Added
- Module will now disable itself if it sees that SHIPPING_ORIGIN_ZIP is not a valid 5-digit or 9-digit ZIP Code.
- Additional warnings are now present on the module line in the listing of modules.
- Added a note to the Debug Log about what the shipping origin zip code setting is.
Changed
- Changed the module's installation message with regards to the measurements. (Going forward, if the store owner changes the setting for `SHIPPING_WEIGHT_UNITS` at the time of installation, the message for the default measurements will also change.)
- Changed the value of "Estimate Time" to "Estimate Transit Time" for the `MODULE_SHIPPING_USPSR_DISPLAY_TRANSIT` constant for clarity. During the upgrade, if "Estimate Time" is the option, it will change to "Estimate Transit Time" automatically.
- Changed the encapsulated plugin's "description" to read a bit better. (This has no function on the operation of the plugin but it was irritating to look at as it referenced parts not available in the regular parts of the module.)
Fixed
- [BUG] Resolved issue [#4]: (Loading the file via Plugin Manager generates a crash). This was resolved by an emergency patch to the release files but is being properly deployed now. (This patch has been undone as the module is now active on the ZenCart Plugins Database.)
- [BUG] Resolved issue [#5]: Stops error message complaining about a `NULL` value for `$order->delivery['street_address']` when searching if a delivery address is either a `PO_BOX` or `STREET` address. This normally happens when you try to use the module on something like the Shipping Estimator where there is no address set.
- [BUG] Resolved issue [#7]: First Class Mail International Service missing from quotes. This was apparently repaired by the USPS API Tech Team. The quote is now reinstated alongside other international quotes. Additionally, both quotes now will carry the estimated value of the cart alongside it. This is important as there are no limits on domestic shipments but there is a limit of roughly $400 for First Class Mail Package Service and a limit of about $600 to as much $5000 for other services (depending on the country). If the request is too much, the quote will not return anything as it is outside of the range. Additionally, international insurance is now properly applied where necessary.
- [BUG] Resolved issue [#8]: Shipping Modules listing crashes when module loads. This happens when the `TABLE_ORDERS` has a `shipping_method` column set to `TEXT` and is filled with larger data. Originally the module, during the `_check()` process, would see if the column was set to be a `VARCHAR(255)`. If it was set to anything but a `VARCHAR(255)`, the module would try to issue an `ALTER TABLE` SQL command and force it to be a `VARCHAR(255)`. This would backfire as ZenCart would catch a MYSQL error on the tune of "Data too big" and just crash the entire backend. This change will now ignore the column if it's set to anything bigger than a `VARCHAR` (namely TEXT, MEDIUMTEXT or BLOB).
- [BUG] Fixed double spacing present on all quoted process names. (These extra spaces weren't visible anywhere else other than the logfile and maybe the raw source code too if you looked hard enough for it.)
Removed
- Dropped International Return Receipt as that service has been deprecated since January 19, 2025.
- Deleted the changelog attached to the release directory and removed the reference from the encapsulated manifest file. Going forward, the manifest should link to the releases tab on the repository at GitHub. The 0.1.0 release manifest also has been changed to match.
===
Going forward, in addition to posting it on the Repository, an encapsulated and non-encapsulated version of the module will be posted to the directory.
-
Re: USPS Shipping (RESTful) (USPSr)
I am trying to install the current version of the USPS shipping module into a new 2.1.0 application.
The README in the plugin download states it is installed using the new Encapsulated Plugin Manager.
How do you add the USPS plugin and install it in the Plugin Manager?
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
jodean
I am trying to install the current version of the USPS shipping module into a new 2.1.0 application.
The README in the plugin download states it is installed using the new Encapsulated Plugin Manager.
How do you add the USPS plugin and install it in the Plugin Manager?
Hi, sorry the language wasn't clear.
When you download the module, either from the ZenCart Plugin Database or off the repository, you'll be given two choices: download the Encapsulated OR download the non-Encapsulated. Download the encapsulated version and there will be a Zip Folder that contains a folder named 'zc_plugin'. Extract the contents of that directory into the matching zc_plugin directory on your ZenCart installation. Visit your ZenCart Admin area and then visit Modules > Plugin Manager and there should be a new option named "USPS Shipping (w/REST API) for Zen Cart". Click on that row, then choose install. And if all worked well, you will see that it has been installed as well as a new option available under Modules > Shipping.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
retched
Hi, sorry the language wasn't clear.When you download the module, either from the ZenCart Plugin Database or off the repository, you'll be given two choices: download the Encapsulated OR download the non-Encapsulated. Download the encapsulated version and there will be a Zip Folder that contains a folder named 'zc_plugin'. Extract the contents of that directory into the matching zc_plugin directory on your ZenCart installation. Visit your ZenCart Admin area and then visit Modules > Plugin Manager and there should be a new option named "USPS Shipping (w/REST API) for Zen Cart". Click on that row, then choose install. And if all worked well, you will see that it has been installed as well as a new option available under Modules > Shipping.
I just tried to download USPS again from the Zencart Plugins and it does not prompt for to download Encapsulated or non-Encapsulated.
-
Re: USPS Shipping (RESTful) (USPSr)
I was able to download a Encapsualted version from Gethub.
-
Re: USPS Shipping (RESTful) (USPSr)
I used the same setup that my 2.0.1 version uses successfully and I get an error in the new USPSr 0.2.1 version.
Error: Missing or malformed access token.
Is the error referring to the USPS API Consumer Key?
I am using the same USPS API Consumer Key in both Zencart versions.
[12-Feb-2025 16:38:27 Europe/Berlin] Request URI: /tennesseetraditionalflies.com/index.php?main_page=checkout_shipping, IP address: ::1, Language id 1#0 C:\xampp\htdocs\tennesseetraditionalflies.com\zc_plugins\USPSRestful\v0.2.1\cata log\includes\modules\shipping\uspsr.php(1706): zen_debug_error_handler()
#1 C:\xampp\htdocs\tennesseetraditionalflies.com\zc_plugins\USPSRestful\v0.2.1\cata log\includes\modules\shipping\uspsr.php(376): uspsr->getBearerToken()
#2 C:\xampp\htdocs\tennesseetraditionalflies.com\includes\classes\shipping.php(257) : uspsr->quote()
#3 C:\xampp\htdocs\tennesseetraditionalflies.com\includes\modules\pages\checkout_sh ipping\header_php.php(185): shipping->quote()
#4 C:\xampp\htdocs\tennesseetraditionalflies.com\index.php(35): require('C:\\xampp\\htdocs...')
--> PHP Warning: Undefined array key "access_token" in C:\xampp\htdocs\tennesseetraditionalflies.com\zc_plugins\USPSRestful\v0.2.1\cata log\includes\modules\shipping\uspsr.php on line 1706.
-
Re: USPS Shipping (RESTful) (USPSr)
Hi. You're using one of the unstable versions. 0.2.1 isn't released yet. Can you try to download one of the releases? 0.2.0 is the current version. Meanwhile I'll look into why that error is coming up at all.
-
Re: USPS Shipping (RESTful) (USPSr)
Additionally, did you also set up your module by providing it a API Key and Secret in the ZenCart admin panel?
That line
Code:
$token = $body['access_token'];
is asking for the access_token from the response.
If possible, can you enable debugging and send me the log file that's generated from the USPSr module?
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
retched
Additionally, did you also set up your module by providing it a API Key and Secret in the ZenCart admin panel?
That line
Code:
$token = $body['access_token'];
is asking for the access_token from the response.
If possible, can you enable debugging and send me the log file that's generated from the USPSr module?
Yes, I used the same setup from my Zencart 2.0.1
Below is the debug.
2025-02-12 19:38:53:
Requesting Token from USPS
Token Request
{
"grant_type": "client_credentials",
"client_id": "725TENNE5719",
"client_secret": "lgf@USPS9491",
"scope": "domestic-prices addresses international-prices service-standards shipments"
}
2025-02-12 19:38:53:
==================================
TOKEN RESPONSE FROM USPS:
{
"error": "invalid_client",
"error_description": "InvalidApiKey: The client application credentials provided in the request are missing, invalid, inactive or not approved for access.",
"error_uri": "https://datatracker.ietf.org/doc/html/rfc6749#page-45"
}
---------------------------------
CommErr (should be 0): 0 -
==================================
USPS Country - $order->delivery[country][iso_code_2]: US
2025-02-12 19:38:53:
USPSRestful Configuration Report
=========================================================
USPSr build: 0.2.1
Quote Request Rate Type: Retail
Quote from main_page: checkout_shipping
Display Transit Time: No
Site Weights Based in: lbs (Pounds)
Site Measurements Based in: Inches
Shipping ZIP Code Origin: 37135
Cart Weight: 0.01 lbs
Total Quote Weight: 0.0165 lbs. , Pounds: 0, Ounces: 0.264
Maximum: 50 Tare Rates: Small/Medium: 65:0 Large: 0:2
Order Handling method: Box, Handling fee Domestic (Order): $1.25, Handling fee International (Order): $5.00
Services Selected:
Domestic Methods: Ground Advantage, Priority
International Methods: - None -
Categories Excluded from Media Mail: - None -
Zip Codes Allowed for USPS Connect : - None -
Add-Ons Enabled (Domestic): - None -
Add-Ons Enabled (International): - None -
Assumed Domestic Package Size - Length: 8.625, Width: 5.375, Height: 1.625
Assumed International Package Size - Length: 8.625, Width: 5.375, Height: 1.625
Are Packages are Machinable? : Irregular
Sort the returned quotes by: Price-LowToHigh
Order is eligible for Media Mail ? YES
Order SubTotal: $3.00
Order Total: $3.29
Uninsurable Portion: $0.00
Insurable Value: $3.29
2025-02-12 19:38:53: Sending Services request to USPS
2025-02-12 19:38:54:
==================================
REQUEST FROM STORE:
{
"originZIPCode": "37135",
"destinationZIPCode": "37135",
"weight": 0.0165,
"length": 8.625,
"width": 5.375,
"height": 1.625,
"mailClasses": [
"USPS_GROUND_ADVANTAGE",
"PRIORITY_MAIL",
"PRIORITY_MAIL_EXPRESS",
"MEDIA_MAIL"
],
"priceType": "RETAIL",
"extraServices": [
],
"itemValue": 3.2924999999999995,
"mailingDate": "2025-02-13"
}
---------------------------------
CommErr (should be 0): 0 -
==================================
USPS Country - $order->delivery[country][iso_code_2]: US
2025-02-12 19:38:54:
==================================
RAW JSON FROM USPS:
{
"apiVersion": "/prices/v3",
"error": {
"code": "401",
"message": "Missing or malformed access token.",
"errors": [
{
"title": "invalid_token",
"detail": "The access token presented with the request is missing or malformed (not a JWT).",
"source": "Access Token"
}
]
}
}
2025-02-12 19:38:54:
===============================================
Reviewing selected method options...
Array
(
[0] => Array
(
[method] => USPS Ground Advantage Machinable Single-piece
[handling] => 1.30
)
[1] => Array
(
[method] => Priority Mail Machinable Single-piece
[handling] => 1.30
)
)
2025-02-12 19:38:54:
===============================================
Building options...
2025-02-12 19:38:54:
===============================================
Revoking Bearer Token...
2025-02-12 19:38:54: Revoking a Token from USPS
Revocation Request
{
"client_id": "725TENNE5719",
"client_secret": "lgf@USPS9491",
"revoke_token": null,
"token_type": "access_token"
}
2025-02-12 19:38:54:
==================================
TOKEN RESPONSE FROM USPS:
{
"error": "invalid_client",
"error_description": "InvalidApiKey: The client application credentials provided in the request are missing, invalid, inactive or not approved for access.",
"error_uri": "https://datatracker.ietf.org/doc/html/rfc6749#page-45"
}
---------------------------------
CommErr (should be 0): 0 -
==================================
USPS Country - $order->delivery[country][iso_code_2]: US
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
jodean
"client_id": "725TENNE5719",
"client_secret": "lgf@USPS9491",
Yup, like I thought. You're using the old WebTools API login details. As stated on the readme:
I already have a USERID and PASSWORD under the old system, but I'm getting error messages while I try to retrieve quotes.
The older USERID and PASSWORD are not valid for the new system. You will need to provision new credentials under the new USPS API system. Additionally, you SHOULD create an entire new USPS Business Account provided that you don't already have one for your business.
You may want to head over to this page and read how to obtain valid API Credentials: https://github.com/retched/ZC-USPSRe...ted#installing
Let me know if you need help. Send me a DM or @retched on Discord.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
retched
Yup, like I thought. You're using the old WebTools API login details. As stated on the readme:
I already have a USERID and PASSWORD under the old system, but I'm getting error messages while I try to retrieve quotes.
The older USERID and PASSWORD are not valid for the new system. You will need to provision new credentials under the new USPS API system. Additionally, you SHOULD create an entire new USPS Business Account provided that you don't already have one for your business.
You may want to head over to this page and read how to obtain valid API Credentials:
https://github.com/retched/ZC-USPSRe...ted#installing
Let me know if you need help. Send me a DM or @retched on Discord.
You were on target. I missed the instructions to set up a new USPS account. Now it works
Thanks
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
jodean
You were on target. I missed the instructions to set up a new USPS account. Now it works
Thanks
No problem. There will be an update coming out soon(?) that will disable the module if it can't grab a key. Writing up now.
-
Re: USPS Shipping (RESTful) (USPSr)
Using 1.5.7c and installed the non-encapsulated version. Couple of issues. In the admin panel the module didn't show and it gave an error because it was looking for uspsr.php in the languages>english>modules>shipping folder. The file is actually named lang.uspsr.php. So I just renamed it to uspsr.php and then the module showed up and I was able to configure it. The module works but it also is not grabbing some of the names correctly. For instance when you get a quote it would show MODULE_SHIPPING_USPSR_TEXT_SHORT_TITLE (Ground Advantage) to the user.
I edited line 245 in the module and just changed it to $this->title = 'United States Postal Service';
It does something similar with the name of the module under the admin>module>shipping.
I was able to edit those to get things looking right. Not sure why its not getting the data from the other files. My issue is with the other usps module you could select the weight for each shipping type. For instance I only want up to 1 lb for ground advantage and priority limited to 1 lb or more. Is there a way to put that option back in or any idea where to edit the files to manually put that back in?
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
spyderrobotics
Using 1.5.7c and installed the non-encapsulated version. Couple of issues. In the admin panel the module didn't show and it gave an error because it was looking for uspsr.php in the languages>english>modules>shipping folder. The file is actually named lang.uspsr.php. So I just renamed it to uspsr.php and then the module showed up and I was able to configure it. The module works but it also is not grabbing some of the names correctly. For instance when you get a quote it would show MODULE_SHIPPING_USPSR_TEXT_SHORT_TITLE (Ground Advantage) to the user.
I edited line 245 in the module and just changed it to $this->title = 'United States Postal Service';
It does something similar with the name of the module under the admin>module>shipping.
I was able to edit those to get things looking right. Not sure why its not getting the data from the other files. My issue is with the other usps module you could select the weight for each shipping type. For instance I only want up to 1 lb for ground advantage and priority limited to 1 lb or more. Is there a way to put that option back in or any idea where to edit the files to manually put that back in?
Right, the USPS/RESTful provides only new-style language files (i.e. lang.uspsr.php); that form of language-file was introduced in zc158.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
spyderrobotics
Using 1.5.7c and installed the non-encapsulated version. Couple of issues. In the admin panel the module didn't show and it gave an error because it was looking for uspsr.php in the languages>english>modules>shipping folder. The file is actually named lang.uspsr.php. So I just renamed it to uspsr.php and then the module showed up and I was able to configure it. The module works but it also is not grabbing some of the names correctly. For instance when you get a quote it would show MODULE_SHIPPING_USPSR_TEXT_SHORT_TITLE (Ground Advantage) to the user.
I edited line 245 in the module and just changed it to $this->title = 'United States Postal Service';
It does something similar with the name of the module under the admin>module>shipping.
I was able to edit those to get things looking right. Not sure why its not getting the data from the other files. My issue is with the other usps module you could select the weight for each shipping type. For instance I only want up to 1 lb for ground advantage and priority limited to 1 lb or more. Is there a way to put that option back in or any idea where to edit the files to manually put that back in?
Quote:
Originally Posted by
lat9
Right, the USPS/RESTful provides only new-style language files (i.e. lang.uspsr.php); that form of language-file was introduced in zc158.
Yeah as lat9 said, I made this for 1.5.8 onward given that the older style of language files are being phased out. It CAN work with some muscle for 1.5.7, but I would have to rewrite all of the language files to do so.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
retched
Yeah as lat9 said, I made this for 1.5.8 onward given that the older style of language files are being phased out. It CAN work with some muscle for 1.5.7, but I would have to rewrite all of the language files to do so.
You SHOULD be able to use the following gists. Just be sure to put the languages file where necessary and rename them. (the admin.uspsr.php should be copied to /admin/includes/languages/english/extra_definitions/uspsr.php and the catalog.uspsr.php file should be copied to catalog\includes\languages\english\modules\shipping\ . Both should be named to JUST uspsr.php)
https://gist.github.com/retched/bcf6...1e472bc741976a
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
spyderrobotics
My issue is with the other usps module you could select the weight for each shipping type
Coming back in a later edit innately (probably the next edit once I fix the quote issue right now). The way I have to pull the JSON file presently is a bit cumbersome but I'm 95% sure it can be done to compare it against a maximum/minimum weight like before.
There is a way to use an observer class (NOTIFY_USPS_UPDATE_OR_DISALLOW_TYPE) to in effect disable a shipping method. But that might be too cumbersome.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
retched
You SHOULD be able to use the following gists. Just be sure to put the languages file where necessary and rename them. (the admin.uspsr.php should be copied to /admin/includes/languages/english/extra_definitions/uspsr.php and the catalog.uspsr.php file should be copied to catalog\includes\languages\english\modules\shipping\ . Both should be named to JUST uspsr.php)
https://gist.github.com/retched/bcf6...1e472bc741976a
Im in a similar situation where I will be stuck in with an older version of ZC until a complete tear down can happen. Which its going to be quite catastrophic since it a 15 year old cart that had been through as much as upgrades as reasonably can. In the light of the USPS api retirement notice, I'm interested to see if this would work reliably in a production environment that really can't be upgraded any further.
Any efforts to provide some reasonable backward compatibility would be greatly appreciated.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
chibipaw
Im in a similar situation where I will be stuck in with an older version of ZC until a complete tear down can happen. Which its going to be quite catastrophic since it a 15 year old cart that had been through as much as upgrades as reasonably can. In the light of the USPS api retirement notice, I'm interested to see if this would work reliably in a production environment that really can't be upgraded any further.
Any efforts to provide some reasonable backward compatibility would be greatly appreciated.
Which version of ZC are you on?
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
retched
Which version of ZC are you on?
With munch embarrassment, 1.55f. Because too many active dependencies that are now abandonware, and this is a very active production site.
-
Re: USPS Shipping (RESTful) (USPSr)
Wait you mean 1.5.5f right?
-
Re: USPS Shipping (RESTful) (USPSr)
Yes, not by choice as mentioned.
-
Re: USPS Shipping (RESTful) (USPSr)
FWIW, given my short code review, I believe that this version of USPS could be made usable on Zen Cart versions prior to 1.5.8 and PHP versions prior to 7.3/4 by
- Providing a non-array-based language file, i.e. using the older define-statement method.
- Changing the use of the null-coalesce operator (??) to use the older tertiary operator, e.g. if (($x ?? 7)) becomes if (isset($x) ? $x : 7).
-
Re: USPS Shipping (RESTful) (USPSr)
If it's at all possible, that is very much appreciated. Im sure not just by me, but buy a lot of people who are kind of stuck in this situation.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
chibipaw
If it's at all possible, that is very much appreciated. Im sure not just by me, but buy a lot of people who are kind of stuck in this situation.
Keep in mind you can continue to use WebTools, the deprecation takes effect in 2026 when USPS plans on turning off WebTools entirely. I'll start setting up for a second side update (most of the logic I don't have to change, luckily) sometime soon but I have a few issues to resolve with the current version first. It's just going to be hard setting up an installation of PHP7 so that I can install ZenCart 1.5.5 and 1.5.7 (for some reason, unless I'm doing something wrong, they REALLY don't want me to install on PHP8).
-
Re: USPS Shipping (RESTful) (USPSr)
I'll keep an eye out for any updates, and if you need someone to test it out.
I have disk images on AWS that I can test on without fear of breaking anything on a production box.
-
Welcome to version 1.0.0! - Changelog
This one is a lot! I've tested on Zencart 2.1.0, 1.5.7, and 1.5.5. Turns out it wasn't PHP8's ?? operator that was causing problems, it was the fact that I had a heredoc with extra spaces in its terminating line (which is OK in PHP8, not OK in PHP7) that was causing problems. Still leaving off the coalescence operator on future releases. Additionally, to help with backwards compatibility, there are now define-based language files for the older ZenCart versions. (These won't cause any problems with the newer array-based language files.)
Breaking
- Due to a change in the configuration for the shipping methods, the selection of current shipping methods will be reset with this version. You must now select your shipping methods to use under USPS. (I tried to avoid these kinds of breaking changes but with the way how the selection of the modules is done and the changes to the table holding them, it's unavoidable. This will normally happen if I have to change the way how the USPS identifies its services.)
- Going forward: if you are using encapsulated version v0.0.0, aka the version pulled straight from the GitHub repository "main" branch, the upgrader will fail. You must do a clean install by uninstalling the module from Plugin Manager from your backend and then installing the new version. The development version of v0.0.0 is to be considered an incomplete thought and should NOT be used in active productions. Non-encapsulated versions will still have to do the same until an upgrader is put in place in the module.
Added
- Module now does a brief test to pull a token. If it succeeds, the module remains enabled. But if it fails for any reason whatsoever, the module turns off. This also generates an error message in the Admin area, additionally the module "soft-disables". (The light turns yellow as if you disabled it.)
- Created language define file for Admin side error messages. (Both the admin and client side language files are array-based for ZC 1.5.8+.)
- New flag: MODULE_SHIPPING_USPSR_DIMENSIONAL_CLASS. This will ask if the packages are "Rectangular" or "Nonrectangular". (Are you shipping your orders in cube-like packaging or are you using something like soft poly bags.) This flag only comes into play if you set the packages to be REALLY big or are shipping packages REALLY heavy. The quote will take care of and include any necessary surcharges.
- New flag: MODULE_SHIPPING_USPSR_CUBIC_CLASS. Sets a flag to either "Non-Soft" or "Soft" packaging types for Cubic pricing. (Same question as Dimensional Class but different pricing scheme.)
- Created a toggle to allow the shop to send the full value of the customer's cart as part of the quoting process or to cap it at $5.00. (Some shipping methods in the USPS are limited based on how much value is being sent through it. This especially applies to international shipments as the USPS caps service modes based not only on destination but also the value of the items being sent.) If this toggle is enabled, the insurance calculations will fall short as the value of the insurance is based on how much the calculated cart total is. Use this setting at your peril.
- A flag for the source of the log file has been made. Any log file generated by an admin's action will be precluded with an _adm_ suffix. (Also a warning that each log file is roughly 300KB. Nothing can be done about that as, for diagnostic purposes, I need not just the diagnostic report but also the raw JSONs being sent and received when trying to figure out what went wrong with the module.)
- Created a debug counter for Ground Advantage Cubic, Priority Mail Cubic, and Priority Mail Express Cubic. This helps for deciding on whether to filter the rate for these services further or to just use what is received.
- Expanded the packaging classes into three questions: one pertaining to Media Mail (Machinable/Nonstandard) and Ground Advantage Cubic and Priority Mail Cubic (Rectangular/Nonrectangular and Soft/Non-Soft).
- Expanded definitions and explanations of various configuration settings.
- Added min/max fields from the original USPS module to shipping method selection. These fields allow you to place weight-based clamps on each method. For example: If you entered 1 and 5 in the appropriate boxes (order does not matter, the software will sort it out for you) for USPS Ground Advantage, the module will only offer your customers the USPS Ground Advantage rate if the total package weight (that is items and tare) is within those two settings. NOTE: This does not mean you can offer services that are outside of the USPS limits. (Example: Entering 80 as a maximum does not mean you can offer Ground Advantage to your customers as 70 is the maximum serviceable weight for USPS Ground Advantage.)
- For parity with ZenCart installations older than 2.0.0, there is a file edit that the storeowner should use to define the measurement standard of the site. This is to make sure that everything is dispatched to the USPS in imperial units. If you are using 2.0.0 or newer, do not edit the file at all.
- (REPO HEALTH) Added a new Feature Request YAML form plus created a Pull Request template.
Fixed
- Full compatibility with ZenCart 1.5.7 AND PHP7. (Technically speaking, the code base was compatible with PHP 7.3 and onward, but 7.1 still required Heredocs to end at the first column of the line. There was an extra indent involved with a heredoc and that caused a lot of problems.)
- Added a catch-all to prevent a bugged API response for Media Mail. In short, the values for Nonstandard Basic were being duplicated. USPS is aware of this but there is no telling of when a fix will come. In the interim, the module will filter out the other responses and proceed with just one. This does mean that your Machinable packages will be treated as Nonstandard. (In most cases, the price should still be the same.)
- Filtered off the PMOD (Priority Mail Open and Distribute) responses as well as duplicated domestic Flat Rates.
- Improved filtering from Media Mail, Ground Advantage Cubic, Priority Mail, and Priority Mail Express services. (Fixes issue #13 from the Github.)
- More "industry" terms filtered out. (Open and Distribute methods are filtered out.)
- Changed USPS Ground Advantage to just read Ground Advantage instead.
- Fixed validation of zipcodes: The module now tries to see if the order has a US destination. If so, disable the module if someone enters something that isn't a 5 or 9-digit zip code.
Changed
- Error messages in the admin backend now use $messageStack instead of attaching it to the row of details.
- Improved README to give directions on how to create API credentials. (Wiki was also created and articles were created there.)
- The internal handling of some of the shipping methods has changed. (Namely USPS Ground Advantage, Priority Mail, Media, and Priority Mail Express. Each of these has a weird naming scheme in the API that was either causing rates to not appear or appear more than once in a non-descriptive way. Also, see issue #13 and various comments on the repository.)
- Changed machinability flag to only apply with Media Mail. The USPS API will automatically determine if a package would be machinable or nonstandard, the term irregular has been retired for other services. However, for Media Mail, the seller will need to provide a bit of detail.
- Renamed MODULE_SHIPPING_USPSR_PROCESSING_CLASS to MODULE_SHIPPING_USPSR_MEDIA_CLASS. This is an internal change. Makes it easier to identify in the code.
- Sanitized the debug logs by hiding the "client secret" from the JSON file that is saved in the log. (It's still dispatched but seeing the secret is not necessary.)
Removed
- Deleted old versions from repository files. The old versions will live in the releases section of the GitHub and ZenCart Release. (This makes it easier to version track.) Going forward, the main directory of the module on the repository will be renamed to 0.0.0 and then each release will have a separate branch with any necessary changes. The "tags" will be based on that targeted branch.
---
Download will be available once approved in ZenCart Module DB. Can also visit the repository and grab the latest release from the links on the side.
If there are any problems or questions, please raise them here.
-
Re: Welcome to version 1.0.0! - Changelog
Noting that the download has been approved: https://www.zen-cart.com/downloads.php?do=file&id=2395
Wow! 'Nuff said.
-
Re: USPS Shipping (RESTful) (USPSr)
Minor Update submitted for approval. Changes are listed below:
---
Added
- The module will now call into the ZenCart Plugin database to see if a new version is available. If there is, you will see a banner on the top of the page alerting you. #19
- Ground Advantage and Ground Advantage Cubic will now be squashed into the cheaper method being offered. Same with Priority Mail and Priority Mail Cubic. #23. (In short, if you have both Priority Mail and Priority Mail Cubic quoted, with the toggle made for Priority Mail, the module will choose the cheaper of the two methods and display that.)
Removed
- Removed the check and comparison to see what format the site is using for shipping and length measurements on upgrades. (It was supposed to check if kilograms was the rate at the time of installation and then convert the defaults to that. Now, the module will check on install, place those defaults, and leave it. This means if you change the measuring standard, you'll have to reset the limits of the shipping methods.)
- Removed the unit of measure from the shipping methods table.
Changed
- Debug mode now has two separate modes: Display Errors, and Generate Logs. If errors are found, they are hidden from the customer view unless toggled on. Additionally, you can generate logs for all requests. (TODO: On any error, generate a log regardless of setting.)
Fixed
- There was a spelling error for "Priority Mail" which made "Priorty Mail". That was fixed.
- Resolved #25: Some error messages still bled through even though there was a series of flags and checks to make sure not to bother with launching the quote. Now the logic is: If the order country is bound to the United States and there is no zip code, the module will not try to get a quote. If the quote is requested for an order going elsewhere, the Zip Code is less important.
---
The ZenCart Module will now have both the regular and encapsulated files listed in one singular entry. Additionally, all version are drag and drop. (Meaning if you installed the regular version of 1.0.0 or earlier, you can just replace the files with the files from the newer version with very little incident.)
Also should be noted that the version numbering SHOULD be fixed. (I was submitting them without the v attached which caused confusing messages in ZenCart if you used the Encapsulated version. Going forward I'll be sure to add it in.)
-
Re: USPS Shipping (RESTful) (USPSr)
How do I get the API keys?
-
Re: USPS Shipping (RESTful) (USPSr)
-
Re: USPS Shipping (RESTful) (USPSr)
I turned restful off so no debug files from it.
ZC 2.1.0 and all below are latest
Bootstrap
EO 5
OPC
POSM
Received the following on first run of encapsulated files from current GitHub
Code:
[03-Mar-2025 18:01:29 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/pages/checkout_one/header_php.php(220): shipping->quote()
#2 /index.php(35): require('/home/enigjohn/...')
#3 {main}
thrown in /zc_plugins/USPSRestful/v0.0.0/catalog/includes/modules/shipping/uspsr.php on line 916
[03-Mar-2025 18:01:29 UTC] Request URI: /index.php?main_page=checkout_one, 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/pages/checkout_one/header_php.php(220): shipping->quote()
#2 /index.php(35): require('/home/enigjohn/...')
#3 {main}
thrown in /zc_plugins/USPSRestful/v0.0.0/catalog/includes/modules/shipping/uspsr.php on line 916.
[03-Mar-2025 18:01:29 UTC] Request URI: /index.php?main_page=checkout_one, 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/pages/checkout_one/header_php.php(220): shipping->quote()
#2 /index.php(35): require('/home/enigjohn/...')
#3 {main}
thrown in /zc_plugins/USPSRestful/v0.0.0/catalog/includes/modules/shipping/uspsr.php on line 916.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
dbltoe
I turned restful off so no debug files from it.
ZC 2.1.0 and all below are latest
Bootstrap
EO 5
OPC
POSM
Received the following on first run of encapsulated files from current GitHub
Code:
[03-Mar-2025 18:01:29 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/pages/checkout_one/header_php.php(220): shipping->quote()
#2 /index.php(35): require('/home/enigjohn/...')
#3 {main}
thrown in /zc_plugins/USPSRestful/v0.0.0/catalog/includes/modules/shipping/uspsr.php on line 916
[03-Mar-2025 18:01:29 UTC] Request URI: /index.php?main_page=checkout_one, 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/pages/checkout_one/header_php.php(220): shipping->quote()
#2 /index.php(35): require('/home/enigjohn/...')
#3 {main}
thrown in /zc_plugins/USPSRestful/v0.0.0/catalog/includes/modules/shipping/uspsr.php on line 916.
[03-Mar-2025 18:01:29 UTC] Request URI: /index.php?main_page=checkout_one, 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/pages/checkout_one/header_php.php(220): shipping->quote()
#2 /index.php(35): require('/home/enigjohn/...')
#3 {main}
thrown in /zc_plugins/USPSRestful/v0.0.0/catalog/includes/modules/shipping/uspsr.php on line 916.
Oh wait, you said you pulled from current.
Edit Orders shouldn't affect it nor should Bootstrap (I actually use Bootstrap myself.)
I have to see what's going on with One Page Checkout.
-
Re: USPS Shipping (RESTful) (USPSr)
So far I can't replicate this, even with Edit Orders. I have each of the above modules installed. Can you let me know of any other details that you would think could replicate this?
-
Re: 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
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
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.
-
Re: USPS Shipping (RESTful) (USPSr)
Have you tried it with Zip + 4 or just a nine-digit zip code?
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
dbltoe
Have you tried it with Zip + 4 or just a nine-digit zip code?
Just the basic four or nine.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
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.
Quote:
Originally Posted by
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?
Quote:
Originally Posted by
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.
Quote:
Originally Posted by
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.)
-
Re: USPS Shipping (RESTful) (USPSr)
For demonstration, this is what happens when I run the API return through a regex tester:
https://i.imgur.com/3qXBxVZ.png
-
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.
Code:
[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.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
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.
Code:
[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
-
Re: USPS Shipping (RESTful) (USPSr)
Have you installed the latest released USPS-r? I thought this was fixed.
-
Re: USPS Shipping (RESTful) (USPSr)
As stated, all items installed are latest GitHub versions.
PM with log sent.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
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.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
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.
-
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.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
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.
Quote:
Originally Posted by
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.
Quote:
Originally Posted by
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.
-
Re: USPS Shipping (RESTful) (USPSr)
Tl;dr: I figured out what went wrong with, everything here. A bugfix will be submitted shortly.
Quote:
Originally Posted by
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.)
Quote:
Originally Posted by
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.)
-
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-USPSRe...ses/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)
-
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.
-
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.
-
Re: USPS Shipping (RESTful) (USPSr)
If this helps, the quote method is called with an argument -see includes/classes/shipping.php line 257
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
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...
https://i.imgur.com/4lfO0vZ.png
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
swguy
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.
Okay I think that explains dbltoe's error log earlier. Will look into this one.
-
Re: USPS Shipping (RESTful) (USPSr)
It might also make sense to review how the old USPS module handles this.
I get that this is a bunch of work. Thanks for helping the project by tackling it.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
swguy
It might also make sense to review how the old USPS module handles this.
I get that this is a bunch of work. Thanks for helping the project by tackling it.
Yup that actually put me on to the right path. Pretty much I just ended up checking to see what the value of $method was and, if set/not empty, only added that to $quotes array. Before this, the entire list was sent to checkout_confirmation and ZenCart only put the first item from the array.
Nonetheless, I have pulled it off. I managed to get ZenCart to play nice with standard and OPC checkout. I still have to look into an odd issue with the date of delivery and days count being plastered twice. (I cannot replicate this, but am looking out for it. If you encounter this, please tell me what options you used (shipping methods, etc.) right away so I can try to replicate it.)
Combined v1.1.1 + v1.1.2 Notes (to the admins of the modules directory, please delete 1.1.1 if it hasn't been published... it's redundant at this point)
What's changed?
Fixed
- (v1.1.1) 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.)
- (v1.1.1) 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)
- (v1.1.2) Resolved issue that users had with selecting a shipping method and having it "stick". (There was an unused method variable that was set by ZenCart that stored the selected method which is used to carry it forward.) (Issue #34)
Download from GitHub: https://github.com/retched/ZC-USPSRe...ses/tag/v1.1.2, ZenCart modules directory coming shortly.
-
Re: USPS Shipping (RESTful) (USPSr)
Just tested - you've got it! Thanks for your diligence.
-
Re: USPS Shipping (RESTful) (USPSr)
Using encapsuilated latest github. 500 error at plugin update.
Code:
[08-Mar-2025 20:54:03 UTC] PHP Fatal error: Uncaught Error: Call to undefined method messageStack::addSession() in /zc_plugins/USPSRestful/v1.1.2/Installer/ScriptedInstaller.php:235
Stack trace:
#0 /includes/classes/PluginSupport/ScriptedInstaller.php(76): ScriptedInstaller->executeUpgrade('v0.0.0')
#1 /includes/classes/PluginSupport/Installer.php(114): Zencart\PluginSupport\ScriptedInstaller->doUpgrade('v0.0.0')
#2 /includes/classes/PluginSupport/Installer.php(59): Zencart\PluginSupport\Installer->executeScriptedUpgrader('/home/enigjohn/...', 'v0.0.0')
#3 /includes/classes/PluginSupport/BasePluginInstaller.php(55): Zencart\PluginSupport\Installer->executeUpgraders('/home/enigjohn/...', 'v0.0.0')
#4 /includes/classes/ViewBuilders/PluginManagerController.php(302): Zencart\PluginSupport\BasePluginInstaller->processUpgrade('USPSRestful', 'v1.1.2', 'v0.0.0')
#5 /includes/classes/ViewBuilders/BaseController.php(37): Zencart\ViewBuilders\PluginManagerController->processActionDoUpgrade()
#6 /jetmar_ENL210/plugin_manager.php(101): Zencart\ViewBuilders\BaseController->processRequest()
#7 /jetmar_ENL210/index.php(16): require('/home/enigjohn/...')
#8 {main}
thrown in /zc_plugins/USPSRestful/v1.1.2/Installer/ScriptedInstaller.php on line 235
[08-Mar-2025 20:54:03 UTC] Request URI: /jetmar_ENL210/index.php?cmd=plugin_manager&page=1&colKey=USPSRestful&action=doUpgrade, IP address: 216.177.186.199
--> PHP Fatal error: Uncaught Error: Call to undefined method messageStack::addSession() in /zc_plugins/USPSRestful/v1.1.2/Installer/ScriptedInstaller.php:235
Stack trace:
#0 /includes/classes/PluginSupport/ScriptedInstaller.php(76): ScriptedInstaller->executeUpgrade('v0.0.0')
#1 /includes/classes/PluginSupport/Installer.php(114): Zencart\PluginSupport\ScriptedInstaller->doUpgrade('v0.0.0')
#2 /includes/classes/PluginSupport/Installer.php(59): Zencart\PluginSupport\Installer->executeScriptedUpgrader('/home/enigjohn/...', 'v0.0.0')
#3 /includes/classes/PluginSupport/BasePluginInstaller.php(55): Zencart\PluginSupport\Installer->executeUpgraders('/home/enigjohn/...', 'v0.0.0')
#4 /includes/classes/ViewBuilders/PluginManagerController.php(302): Zencart\PluginSupport\BasePluginInstaller->processUpgrade('USPSRestful', 'v1.1.2', 'v0.0.0')
#5 /includes/classes/ViewBuilders/BaseController.php(37): Zencart\ViewBuilders\PluginManagerController->processActionDoUpgrade()
#6 /jetmar_ENL210/plugin_manager.php(101): Zencart\ViewBuilders\BaseController->processRequest()
#7 /jetmar_ENL210/index.php(16): require('/home/enigjohn/...')
#8 {main}
thrown in /zc_plugins/USPSRestful/v1.1.2/Installer/ScriptedInstaller.php on line 235.
[08-Mar-2025 20:54:03 UTC] Request URI: /jetmar_ENL210/index.php?cmd=plugin_manager&page=1&colKey=USPSRestful&action=doUpgrade, IP address: 216.177.186.199
--> PHP Fatal error: Uncaught Error: Call to undefined method messageStack::addSession() in /zc_plugins/USPSRestful/v1.1.2/Installer/ScriptedInstaller.php:235
Stack trace:
#0 /includes/classes/PluginSupport/ScriptedInstaller.php(76): ScriptedInstaller->executeUpgrade('v0.0.0')
#1 /includes/classes/PluginSupport/Installer.php(114): Zencart\PluginSupport\ScriptedInstaller->doUpgrade('v0.0.0')
#2 /includes/classes/PluginSupport/Installer.php(59): Zencart\PluginSupport\Installer->executeScriptedUpgrader('/home/enigjohn/...', 'v0.0.0')
#3 /includes/classes/PluginSupport/BasePluginInstaller.php(55): Zencart\PluginSupport\Installer->executeUpgraders('/home/enigjohn/...', 'v0.0.0')
#4 /includes/classes/ViewBuilders/PluginManagerController.php(302): Zencart\PluginSupport\BasePluginInstaller->processUpgrade('USPSRestful', 'v1.1.2', 'v0.0.0')
#5 /includes/classes/ViewBuilders/BaseController.php(37): Zencart\ViewBuilders\PluginManagerController->processActionDoUpgrade()
#6 /jetmar_ENL210/plugin_manager.php(101): Zencart\ViewBuilders\BaseController->processRequest()
#7 /jetmar_ENL210/index.php(16): require('/home/enigjohn/...')
#8 {main}
thrown in /zc_plugins/USPSRestful/v1.1.2/Installer/ScriptedInstaller.php on line 235.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
dbltoe
Using encapsuilated latest github. 500 error at plugin update.
Code:
[08-Mar-2025 20:54:03 UTC] PHP Fatal error: Uncaught Error: Call to undefined method messageStack::addSession() in /zc_plugins/USPSRestful/v1.1.2/Installer/ScriptedInstaller.php:235
Stack trace:
#0 /includes/classes/PluginSupport/ScriptedInstaller.php(76): ScriptedInstaller->executeUpgrade('v0.0.0')
#1 /includes/classes/PluginSupport/Installer.php(114): Zencart\PluginSupport\ScriptedInstaller->doUpgrade('v0.0.0')
#2 /includes/classes/PluginSupport/Installer.php(59): Zencart\PluginSupport\Installer->executeScriptedUpgrader('/home/enigjohn/...', 'v0.0.0')
#3 /includes/classes/PluginSupport/BasePluginInstaller.php(55): Zencart\PluginSupport\Installer->executeUpgraders('/home/enigjohn/...', 'v0.0.0')
#4 /includes/classes/ViewBuilders/PluginManagerController.php(302): Zencart\PluginSupport\BasePluginInstaller->processUpgrade('USPSRestful', 'v1.1.2', 'v0.0.0')
#5 /includes/classes/ViewBuilders/BaseController.php(37): Zencart\ViewBuilders\PluginManagerController->processActionDoUpgrade()
#6 /jetmar_ENL210/plugin_manager.php(101): Zencart\ViewBuilders\BaseController->processRequest()
#7 /jetmar_ENL210/index.php(16): require('/home/enigjohn/...')
#8 {main}
thrown in /zc_plugins/USPSRestful/v1.1.2/Installer/ScriptedInstaller.php on line 235
[08-Mar-2025 20:54:03 UTC] Request URI: /jetmar_ENL210/index.php?cmd=plugin_manager&page=1&colKey=USPSRestful&action=doUpgrade, IP address: 216.177.186.199
--> PHP Fatal error: Uncaught Error: Call to undefined method messageStack::addSession() in /zc_plugins/USPSRestful/v1.1.2/Installer/ScriptedInstaller.php:235
Stack trace:
#0 /includes/classes/PluginSupport/ScriptedInstaller.php(76): ScriptedInstaller->executeUpgrade('v0.0.0')
#1 /includes/classes/PluginSupport/Installer.php(114): Zencart\PluginSupport\ScriptedInstaller->doUpgrade('v0.0.0')
#2 /includes/classes/PluginSupport/Installer.php(59): Zencart\PluginSupport\Installer->executeScriptedUpgrader('/home/enigjohn/...', 'v0.0.0')
#3 /includes/classes/PluginSupport/BasePluginInstaller.php(55): Zencart\PluginSupport\Installer->executeUpgraders('/home/enigjohn/...', 'v0.0.0')
#4 /includes/classes/ViewBuilders/PluginManagerController.php(302): Zencart\PluginSupport\BasePluginInstaller->processUpgrade('USPSRestful', 'v1.1.2', 'v0.0.0')
#5 /includes/classes/ViewBuilders/BaseController.php(37): Zencart\ViewBuilders\PluginManagerController->processActionDoUpgrade()
#6 /jetmar_ENL210/plugin_manager.php(101): Zencart\ViewBuilders\BaseController->processRequest()
#7 /jetmar_ENL210/index.php(16): require('/home/enigjohn/...')
#8 {main}
thrown in /zc_plugins/USPSRestful/v1.1.2/Installer/ScriptedInstaller.php on line 235.
[08-Mar-2025 20:54:03 UTC] Request URI: /jetmar_ENL210/index.php?cmd=plugin_manager&page=1&colKey=USPSRestful&action=doUpgrade, IP address: 216.177.186.199
--> PHP Fatal error: Uncaught Error: Call to undefined method messageStack::addSession() in /zc_plugins/USPSRestful/v1.1.2/Installer/ScriptedInstaller.php:235
Stack trace:
#0 /includes/classes/PluginSupport/ScriptedInstaller.php(76): ScriptedInstaller->executeUpgrade('v0.0.0')
#1 /includes/classes/PluginSupport/Installer.php(114): Zencart\PluginSupport\ScriptedInstaller->doUpgrade('v0.0.0')
#2 /includes/classes/PluginSupport/Installer.php(59): Zencart\PluginSupport\Installer->executeScriptedUpgrader('/home/enigjohn/...', 'v0.0.0')
#3 /includes/classes/PluginSupport/BasePluginInstaller.php(55): Zencart\PluginSupport\Installer->executeUpgraders('/home/enigjohn/...', 'v0.0.0')
#4 /includes/classes/ViewBuilders/PluginManagerController.php(302): Zencart\PluginSupport\BasePluginInstaller->processUpgrade('USPSRestful', 'v1.1.2', 'v0.0.0')
#5 /includes/classes/ViewBuilders/BaseController.php(37): Zencart\ViewBuilders\PluginManagerController->processActionDoUpgrade()
#6 /jetmar_ENL210/plugin_manager.php(101): Zencart\ViewBuilders\BaseController->processRequest()
#7 /jetmar_ENL210/index.php(16): require('/home/enigjohn/...')
#8 {main}
thrown in /zc_plugins/USPSRestful/v1.1.2/Installer/ScriptedInstaller.php on line 235.
I keep forgetting to not make that spelling error. Can you change the addSession to add_session for line 235.
Additionally, if you're going from 0.0.0 to a version, you should clear the old version out anyway.
-
Re: USPS Shipping (RESTful) (USPSr)
That worked but still getting the double est. delivey on the second option.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
dbltoe
That worked but still getting the double est. delivey on the second option.
Same configuration as before? Bootstrap + OPC + Edit Orders?
Do you still get this error on normal checkout by chance? Also what version of PHP do you use by chance?
-
Re: USPS Shipping (RESTful) (USPSr)
same config and error is on estimator first.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
dbltoe
same config and error is on estimator first.
Are there any other modules or add-ons that you are running? Any kind of observer that could conflict?
-
1 Attachment(s)
Re: USPS Shipping (RESTful) (USPSr)
Here's the list, but I don't see how any of them could mess with the shipping estimator.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
dbltoe
Here's the list, but I don't see how any of them could mess with the shipping estimator.
And can yu let me know what settings you have selected for the module? Just copy/paste the view from the Shipping Module screen. (The view before you use the edit button)
-
Re: USPS Shipping (RESTful) (USPSr)
-
Re: USPS Shipping (RESTful) (USPSr)
That's a funky copy, but maybe it will help.
-
Re: USPS Shipping (RESTful) (USPSr)
Send me a screen cap of the configuration screen. I don't need the API Key and Secret. Just need to see how it is all configured.
-
Double posting of estimated delivery date or delivery time.
Quote:
Originally Posted by
retched
I still have to look into an odd issue with the date of delivery and days count being plastered twice. (I cannot replicate this, but am looking out for it. If you encounter this, please tell me what options you used (shipping methods, etc.) right away so I can try to replicate it.)
Okay an update here: a fix for this is available, but it's kind of hacky.
In uspsr.php (if encapsulated, "\zc_plugins\USPSRestful\v1.1.2\catalog\includes\modules\shipping\". Unencapsulated "\includes\modules\shipping\")
Around line 942, find this:
PHP Code:
$quote['title'] .= " [" . MODULE_SHIPPING_USPSR_TEXT_ESTIMATED_DELIVERY . " " . $est_delivery . "]";
Replace the above with:
PHP Code:
if (strpos($quote['title'], MODULE_SHIPPING_USPSR_TEXT_ESTIMATED_DELIVERY) === FALSE) $quote['title'] .= " [" . MODULE_SHIPPING_USPSR_TEXT_ESTIMATED_DELIVERY . " " . $est_delivery . "]";
Around line 947, find this:
PHP Code:
$quote['title'] .= " [" . MODULE_SHIPPING_USPSR_TEXT_ESTIMATED . " " . zen_uspsr_estimate_days($standard['serviceStandard']) . "]";
Replace the above with:
PHP Code:
if (strpos($quote['title'], MODULE_SHIPPING_USPSR_TEXT_ESTIMATED) === FALSE) $quote['title'] .= " [" . MODULE_SHIPPING_USPSR_TEXT_ESTIMATED . " " . zen_uspsr_estimate_days($standard['serviceStandard']) . "]";
---
In essence, the module will check to see if there is already a copy of the string "est. delivery" or "est." as necessary. If there is not, include it. If there is, skip and do not. For some reason, the module will run itself twice and doing so caused it to add the estimate delivery time twice as well. I'll do an investigation into the code to see what could potentially cause this. But for right now, this should do.
This will be included in 1.1.3 to be released next month alongside any other fixes or improvements.
-
Re: Double posting of estimated delivery date or delivery time.
Finally back from my travels so I can check this new module out, but I didn't get too far with it, and could use some help.
I've downloaded ver 1.1.2 Non-Encapsulated from the git repository. Copies the files where it needs to be, but it doesn't seem to work with my setup.
Once clicking on the "install" button in the admin page, it returned to the shipping module page with the module sort order/status as yellow, and no other dialogs.
Clicking on another module, then clicking on USPSr again gives me an Edit button, doesn't it doesn't actually allow me to edit anything, as the column will remain blank.
Top of the menu screen shows these errors:
USPSr Error: No services selected for USPSr module.
USPSr Error: You didn't enter an API Key and Secret. Please follow the instructions and log in to the developers dashboard to obtain your Consumer Secret and Consumer Key
Nothing I can see in the logs in the zen-cart logs directory.
This is my current configuration:
ZC Version 1.55f
PHP 7.1
MariaDB 1.44
original USPS module is installed.
Aside from the DB , Im kinda stuck in this ZC and Php version due to a number of abandonware that is in used in my production shopping cart.
-
Re: Double posting of estimated delivery date or delivery time.
Quote:
Originally Posted by
chibipaw
Finally back from my travels so I can check this new module out, but I didn't get too far with it, and could use some help.
I've downloaded ver 1.1.2 Non-Encapsulated from the git repository. Copies the files where it needs to be, but it doesn't seem to work with my setup.
Once clicking on the "install" button in the admin page, it returned to the shipping module page with the module sort order/status as yellow, and no other dialogs.
Clicking on another module, then clicking on USPSr again gives me an Edit button, doesn't it doesn't actually allow me to edit anything, as the column will remain blank.
Top of the menu screen shows these errors:
USPSr Error: No services selected for USPSr module.
USPSr Error: You didn't enter an API Key and Secret. Please follow the instructions and log in to the developers dashboard to obtain your Consumer Secret and Consumer Key
Nothing I can see in the logs in the zen-cart logs directory.
This is my current configuration:
ZC Version 1.55f
PHP 7.1
MariaDB 1.44
original USPS module is installed.
Aside from the DB , Im kinda stuck in this ZC and Php version due to a number of abandonware that is in used in my production shopping cart.
If you're getting a half resolved page like that, that means there was an error. Can you check your logs directory and see if one generated?
-
Re: Double posting of estimated delivery date or delivery time.
Quote:
Originally Posted by
retched
If you're getting a half resolved page like that, that means there was an error. Can you check your logs directory and see if one generated?
I did, and I didn't see anything in there at all, thats the puzzling part.
-
Re: Double posting of estimated delivery date or delivery time.
Quote:
Originally Posted by
chibipaw
I did, and I didn't see anything in there at all, thats the puzzling part.
I'm 90% sure I found those errors. Working on it now.
Evidently some of the functions I used, weren't always used in ZC. Fix coming shortly.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
jodean
I just tried to download USPS again from the Zencart Plugins and it does not prompt for to download Encapsulated or non-Encapsulated.
As soon as it's on the repo, I'll be first to test it out! Thank you for working on this.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
chibipaw
As soon as it's on the repo, I'll be first to test it out! Thank you for working on this.
Technically it's there now. I merged in two sets of patches to the main branch.
Copy the uspsr.php found here. And just copy it over your 1.1.2 file. If it works, let me know here. If it doesn't work, let me know here.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
retched
Technically it's there now. I merged in two sets of patches to the main branch.
Copy the uspsr.php
found here. And just copy it over your 1.1.2 file. If it works, let me know here. If it doesn't work, let me know here.
I should also warn that you'll get warnings in the admin area as the main branch will (now) always be coded as 0.0.0. (I do it this way because I'm never consistent with the numbering.)
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
retched
Technically it's there now. I merged in two sets of patches to the main branch.
Copy the uspsr.php
found here. And just copy it over your 1.1.2 file. If it works, let me know here. If it doesn't work, let me know here.
Hurray! The admin panel loads! Menu looks very familiar from the original USPS module. I dont yet have a new USPS API Consumer Key yet, but I will be getting one and be start running tests soon. Let's hope this is biggest and the last hurdle with legacy compatibility.
-
Re: USPS Shipping (RESTful) (USPSr)
Did some basic testing, looks like most everything work with both customer end and admin end.
The only thing that seems to be bugged is the admin side. If you select any add on domestic add on services, you can't remove all of them. One will always linger.
havent tried the international side yet.
Unrelated note, I just realized Global Express Guaranteed (GXG) is no longer offered. Interesting.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
chibipaw
Did some basic testing, looks like most everything work with both customer end and admin end.
The only thing that seems to be bugged is the admin side. If you select any add on domestic add on services, you can't remove all of them. One will always linger.
havent tried the international side yet.
Unrelated note, I just realized Global Express Guaranteed (GXG) is no longer offered. Interesting.
GXG is currently retired as of 2024. Same with International Return Receipt (earlier this year). I'll look in to matter of unselecting methods. Can you let me know which ones are stuck?
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
retched
GXG is currently retired as of 2024. Same with International Return Receipt (earlier this year). I'll look in to matter of unselecting methods. Can you let me know which ones are stuck?
Didn't know at all about the latter one. Thanks.
As for which one gets stuck, it doesn't seem to be specific. It's whatever that is last on the list if you de-select them one by one.
If you de-select them in bulk, none of them will be removed.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
chibipaw
Didn't know at all about the latter one. Thanks.
As for which one gets stuck, it doesn't seem to be specific. It's whatever that is last on the list if you de-select them one by one.
If you de-select them in bulk, none of them will be removed.
Yup I got the same problem. Already logged and testing through it now.
-
Re: USPS Shipping (RESTful) (USPSr)
Zen Cart 2.1
PHP 8.3
I'm getting this error
#0 /zc_plugins/USPSRestful/v1.1.2/catalog/includes/modules/shipping/uspsr.php(1699): zen_debug_error_handler()
#1 /zc_plugins/USPSRestful/v1.1.2/catalog/includes/modules/shipping/uspsr.php(294): uspsr->update_status()
#2 /includes/classes/shipping.php(112): uspsr->__construct()
#3 /includes/classes/shipping.php(55): shipping->initialize_modules()
#4 /includes/modules/pages/checkout_one/header_php.php(182): shipping->__construct()
#5 /index.php(35): require('...')
--> PHP Warning: foreach() argument must be of type array|object, string given in /zc_plugins/USPSRestful/v1.1.2/catalog/includes/modules/shipping/uspsr.php on line 1699.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
brian70809
Zen Cart 2.1
PHP 8.3
I'm getting this error
#0 /zc_plugins/USPSRestful/v1.1.2/catalog/includes/modules/shipping/uspsr.php(1699): zen_debug_error_handler()
#1 /zc_plugins/USPSRestful/v1.1.2/catalog/includes/modules/shipping/uspsr.php(294): uspsr->update_status()
#2 /includes/classes/shipping.php(112): uspsr->__construct()
#3 /includes/classes/shipping.php(55): shipping->initialize_modules()
#4 /includes/modules/pages/checkout_one/header_php.php(182): shipping->__construct()
#5 /index.php(35): require('...')
--> PHP Warning: foreach() argument must be of type array|object, string given in /zc_plugins/USPSRestful/v1.1.2/catalog/includes/modules/shipping/uspsr.php on line 1699.
Wait, that is ...
PHP Code:
foreach ($check->fields['zone_id'] as $zone) {
if ($zone < 1 || $zone === $order->delivery['zone_id']) $check_flag = true;
}
Did you enable the geo blocking feature? Need a bit more about the configuration of the module to start tracking this down.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
retched
Wait, that is ...
PHP Code:
foreach ($check->fields['zone_id'] as $zone) {
if ($zone < 1 || $zone === $order->delivery['zone_id']) $check_flag = true;
}
Did you enable the geo blocking feature? Need a bit more about the configuration of the module to start tracking this down.
Huh... figured this one out. Evidently I should not use foreach loops when pulling from the database. Patch for this one coming shortly.
-
Never Version 1.2.0 Released
To non-encapsulated users: starting with 1.1.0, you can simply overwrite the installation by extracting the files as directed. If there were any database changes, the module will self-correct.
Fixed
- Fixed an issue where the estimated delivery and estimated day count would repeat twice. (Ex: "USPS (Priority Mail [est. delivery 03/09/2025] [est. delivery 03/09/2025])" ) Still not sure where it came from but it's resolved. [#36]
- Fixed an issue where an older version of ZenCart would try to invoke zen_db_perform with capitalized commands (`UPDATE` instead of `update`) and ZC just doesn't know what to do. [#40]
- Fixed an issue where after selecting add-ons, you couldn't clear all of them off in bulk. In short, you had to leave one up and deselect the others. [#42]
- Fixed an issue where the originating JSON request wasn't being attached to the log. [#43]
- Fixed an issue that caused a crash when using the "Shipping Zones" function to limit where the module should be allowed. (This evidently was also an issue in lat9's USPS module as they were trying to move away from the legacy form of traversing `$db` output. Whenever the `MoveNext()` functionality is removed, that will cause a breaking change in the module as older ZC's will be left out.) [#44]
---
This zip file includes both the Encapsulated and Non-Encapsulated forms of the module. Please read the directions of the included README.html or README.md to see how to install it and which versions of ZenCart can use which versions.
I'm off to bed.
Version is submitted to the module directory. Available on GitHub under Releases.
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
retched
Huh... figured this one out. Evidently I should not use foreach loops when pulling from the database. Patch for this one coming shortly.
Thank you!
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
retched
USPS Shipping (RESTful) for Zen Cart
This module provides sellers a chance to offer United States Postal Service (USPS) shipping rates to customers during checkout. This is done by pulling the rates directly from the USPS' REST API.
This module supports versions 1.5.8 onward innately. (Support from 1.5.7 and backward is not necessarily guaranteed but is plausible. Read the Installation steps below for more details.) This script was primarily written with PHP8 in mind. (It might have problems working with PHP7.)
There isn't much difference between the two versions. However, if you managed to get the WebTools version to work, CONTINUE TO USE THAT VERSION.
USPS API Documentation: https://developers.usps.com/apis
This API takes advantage of four API's: Domestic Prices 3.0, International Prices 3.0, Service Standards 3.0, and OAuth 3.0.
ZenCart Plugins Download: https://www.zen-cart.com/downloads.php?do=file&id=2395 (Pending)
(or use the Releases function on the GitHub repository)
GitHub Repository: https://github.com/retched/ZC-USPSRestful
** This thread is only for the USPSr version of the USPS module. For assistance with the original USPS module which uses the WebTools API, you should post in its megathread: https://www.zen-cart.com/showthread....Support-Thread
I have my account on USPS all setup on USPS, but I'm getting the following error with the USPS module:
2025-03-24 00:04:10:
Requesting Token from USPS
Token Request
{
"grant_type": "client_credentials",
"client_id": "**REDACTED**",
"scope": "domestic-prices addresses international-prices service-standards shipments"
}
2025-03-24 00:04:10:
==================================
TOKEN RESPONSE FROM USPS:
null
---------------------------------
CommErr (should be 0): 60 - SSL certificate problem: unable to get local issuer certificate
==================================
Zen Cart 2.1.0
Window Server 2022 - IIS 10.5
PHP 8.4.5
MySQL 8.0.41.0
-
Re: USPS Shipping (RESTful) (USPSr)
I just updated to all the new stuff. Upgraded my zencart to 2.1.0 and now using this plugin and not the old one for USPS. No clue what's going on. I have an item that is 1 oz and when i put in my zip code to get shipping estimate it shows $22.40 for ground advantage In the old system it would only be just over $5 https://thecubden.org/store
-
Re: USPS Shipping (RESTful) (USPSr)
I just went in and checked the settings, resaved the info and it looks good now
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
cubmanky
I just went in and checked the settings, resaved the info and it looks good now
Quote:
Originally Posted by
cubmanky
I just updated to all the new stuff. Upgraded my zencart to 2.1.0 and now using this plugin and not the old one for USPS. No clue what's going on. I have an item that is 1 oz and when i put in my zip code to get shipping estimate it shows $22.40 for ground advantage In the old system it would only be just over $5
https://thecubden.org/store
Can I know what was changed that caused such a massive swing?
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
retched
Can I know what was changed that caused such a massive swing?
No clue. I just resaved the settings.
-
Re: USPS Shipping (RESTful) (USPSr)
I have several categories and products I cannot use USPS.
In the other USPS module, I was able to modify usps.php and add categories and products to exclude from using USPS. I thought I might be able to do the same with the uspsr.php but it is very different. Can I modify the file and where would I do this? would add this to the file:
//bof: Skip and only use UPS
$chk_cart = 0;
$chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id','4854');
$chk_cart += $_SESSION['cart']->in_cart_check('products_id','4');
//bof: Skip and only use UPS
$chk_cart = 0;
Thank you
-
Re: USPS Shipping (RESTful) (USPSr)
Quote:
Originally Posted by
n8pbm
I have several categories and products I cannot use USPS.
In the other USPS module, I was able to modify usps.php and add categories and products to exclude from using USPS. I thought I might be able to do the same with the uspsr.php but it is very different. Can I modify the file and where would I do this? would add this to the file:
//bof: Skip and only use UPS
$chk_cart = 0;
$chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id','4854');
$chk_cart += $_SESSION['cart']->in_cart_check('products_id','4');
//bof: Skip and only use UPS
$chk_cart = 0;
Thank you
never modify core code when you do not have to.
try and play along.
create an auto-loading observer. also this post.
that you want to observer this notifier.
if you have successfully gotten that far, you can then add your code as follows:
PHP Code:
public function updateNotifyShippingUspsUpdateStatus(&$class)
{
$chk_cart = 0;
$chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id', '4854');
$chk_cart += $_SESSION['cart']->in_cart_check('products_id', '4');
if ($chk_cart > 0) {
$class->enabled = false;
}
}
best.