Forums / Addon Shipping Modules / USPS Shipping Module [Support Thread]

USPS Shipping Module [Support Thread]

Sticky
Results 1 to 20 of 447
09 Oct 2020, 11:33
#1
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Posts:
13,980
Plugin Contributions:
46
21 Oct 2020, 12:58
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Posts:
13,980
Plugin Contributions:
46

Re: USPS Shipping Module [Support Thread]

Version 2020-09-24 K11 is now available for download: https://www.zen-cart.com/downloads.php?do=file&id=1292

Note that this version is not compatible with Zen Cart versions prior to 1.5.2 and is not supported for Zen Cart versions prior to 1.5.4.

The following changes were made:

- Restructuring to prevent PHP notices and warnings.
- Re-factored to use now-current code styling.
- Includes modifications to use stripos/strpos instead of preg_match for 'simple' string-in-string checks.
- Use foreach() instead of deprecated each()
- Use secure (https: //secure.shippingapis.com/ShippingAPI.dll) endpoint for API requests; unsecure endpoint being retired.
- Simplifies debug handling, 'Screen' and 'Email' no longer supported.
- Debug filename changed to enable sort-by-name to mimic sort-by-date on the files.
- Restores the USPS icon to this shipping-method's distribution zip-file.
- Correct missing constant warning (MODULE_SHIPPING_USPS_REGULATIONS)
- That 'soft' configuration setting is now available in the usps.php language file.
- Additional, previously undefined language constants added in support of the display.
- 'Return Receipt for Merchandise [107]' retired and USPS will return an error if requested.
- Country name changes:
- Country ('MK') changed from 'Macedonia, Republic of' to 'North Macedonia, Republic of'.
- Country ('SZ') changed from 'Swaziland' to 'Eswatini'.
- Country ('SS') added (South Sudan); note that the country is not currently registered in the countries table.
- Add 'soft' configuration settings, present in the module's language file (refer to that file for additional information):
- MODULE_SHIPPING_USPS_SHIPPING_CUTOFF ... the shipping cut-off time, used to determine the delivery date.
- MODULE_SHIPPING_USPS_GROUNDONLY ... identifies whether the database field 'products::products_groundonly' should be interrogated.
- MODULE_SHIPPING_USPS_FRAGILE ... identifies whether the database field 'products::products_fragile' should be interrogated.
- Remove fallback 'plugin_check_for_updates' function. It's now expected to be present as part of the base Zen Cart distribution (zc152+).
- Auto-disable on the storefront if no shipping services have been selected or if the store's country-of-origin isn't the US (country code 223).
24 Oct 2020, 00:15
#3
webskipper avatar

webskipper

Totally Zenned

Join Date:
Nov 2007
Posts:
876
Plugin Contributions:
2

Re: USPS Shipping Module [Support Thread]

Thanks lat9 for the refresh and xoxo to Ajeh for all her efforts (past, present, and future), too.

Where would the 'if clause' be inserted in this update to create a USPS Minimum Shipping Cost? Example $6 for 1st Class.
USPS_2020_09_24_K11>includes>modules>shipping>usps.php @line 779 ?

Was using this in previous versions. Thanks in advance.


$methods[] = array('id' => $type, 'title' => $this->types[$type], 'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);

to now force the amount ...
Code:

if ($cost < 6.00) { $methods[] = array('id' => $type, 'title' => $this->types[$type], 'cost' => (6.00 + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);} else { $methods[] = array('id' => $type, 'title' => $this->types[$type], 'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
24 Oct 2020, 11:11
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Posts:
13,980
Plugin Contributions:
46

Re: USPS Shipping Module [Support Thread]

@webskipper, find the following code fragment, starting at line 724:
            // add handling for shipping method costs for extra services applied
            $cost_original = $cost;
            $cost = ($cost + $handling + $hiddenCost) * $shipping_num_boxes;
            // add handling fee per Box or per Order
            $cost += (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box') ? $usps_handling_fee * $shipping_num_boxes : $usps_handling_fee;

and add the highlighted code fragments:
            // add handling for shipping method costs for extra services applied
            $cost_original = $cost;

//-bof-Force minimum cost of $6.00
            if ($cost < 6) {
                $cost = 6;
            }
//-eof-Force minimum cost

            $cost = ($cost + $handling + $hiddenCost) * $shipping_num_boxes;
            // add handling fee per Box or per Order
            $cost += (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box') ? $usps_handling_fee * $shipping_num_boxes : $usps_handling_fee;
24 Oct 2020, 16:22
#5
webskipper avatar

webskipper

Totally Zenned

Join Date:
Nov 2007
Posts:
876
Plugin Contributions:
2

Re: USPS Shipping Module [Support Thread]

Worked like magic! Thanks.

Donated a Jackson.
01 Nov 2020, 21:41
#6
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Posts:
10,620
Plugin Contributions:
212

Re: USPS Shipping Module [Support Thread]

I will periodically see

--> PHP Warning: count(): Parameter must be an array or an object that implements Countable in /SITE/includes/modules/shipping/usps.php on line 492. // line 487 in an unmodified file

where that line is

$PackageSize = count($uspsQuote['Package']['Service']);

This is the else branch of $this->is_us_shipment.

Is it possible this branch needs the same check as the other branch, where we check count($uspsQuote['Package']); (line 480).
02 Nov 2020, 12:28
#7
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Posts:
13,980
Plugin Contributions:
46

Re: USPS Shipping Module [Support Thread]

swguy:

I will periodically see

--> PHP Warning: count(): Parameter must be an array or an object that implements Countable in /SITE/includes/modules/shipping/usps.php on line 492. // line 487 in an unmodified file

where that line is

$PackageSize = count($uspsQuote['Package']['Service']);

This is the else branch of $this->is_us_shipment.

Is it possible this branch needs the same check as the other branch, where we check count($uspsQuote['Package']); (line 480).

Quite possible!

What international methods and services does the site offer?
Do you have any insight into the ship-to country/zone/postcode used when the warning was issued?
02 Nov 2020, 20:32
#8
craftcorner avatar

craftcorner

New Zenner

Join Date:
Dec 2017
Posts:
44
Plugin Contributions:
0

Re: USPS Shipping Module [Support Thread]

Recently upgraded to 1.5.7 of ZC, but have not been able to import orders to stamps.com since Saturday. Should I have my web person install this module, or is it included in 1.5.7? Trying to figure out why I can't import; I have the updated php file that DrByte wrote, and it was working fine until today.
03 Nov 2020, 11:18
#9
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Posts:
13,980
Plugin Contributions:
46

Re: USPS Shipping Module [Support Thread]

CraftCorner:

Recently upgraded to 1.5.7 of ZC, but have not been able to import orders to stamps.com since Saturday. Should I have my web person install this module, or is it included in 1.5.7? Trying to figure out why I can't import; I have the updated php file that DrByte wrote, and it was working fine until today.

The USPS shipping module must be installed separately from the 'base' Zen Cart files. Note that the shipping-module has no effect on the ShipStation import; it's only active during a site's checkout.
13 Nov 2020, 00:33
#10
wulf359 avatar

wulf359

New Zenner

Join Date:
Feb 2008
Posts:
44
Plugin Contributions:
0

Re: USPS Shipping Module [Support Thread]

I'm trying to get this working on Zencart 1.5.5f and keep getting an error on the checkout page that says:

"An error occurred in obtaining USPS shipping quotes.
If you prefer to use USPS as your shipping method, please try refreshing this page, or contact the store owner."

I've turned on debugging and the log has the following (I've replaced the username):

2020-11-12 18:28:26: USPS build: 2020-09-24 K11

Server: production
Quote Request Rate Type: Retail
Quote from main_page: checkout_shipping
USPS Options (weight, time): --none--
USPS Domestic Transit Time Calculation Mode: CUSTOM
Cart Weight: 0.5
Total Quote Weight: 0.5 Pounds: 0 Ounces: 8
Maximum: 50 Tare Rates: Small/Medium: 0 Large: 0
Handling method: Box Handling fee Domestic: $0.00 Handling fee International: $0.00
Decimals: 3
Domestic Length: 8.625 Width: 5.375 Height: 1.625
International Length: 9.50 Width: 1.0 Height: 5.50
All Packages are Machinable: False
Enable USPS First-Class filter for US shipping: True
Sorts the returned quotes: Unsorted

ZipOrigination: 92065
ZipDestination: Postcode: 32570 Country: United States City: Milton State: Florida
Order SubTotal: $34.95
Order Total: $34.95
Uninsurable Portion: $0.00
Insurable Value: $34.95

2020-11-12 18:28:26: Sending request to USPS

2020-11-12 18:28:41: ==================================

SENT TO USPS:

<RateV4Request USERID="**********"><Revision>2</Revision>
<Package ID="0"><Service>First Class</Service><FirstClassMailType>FLAT</FirstClassMailType><ZipOrigination>92065</ZipOrigination><ZipDestination>32570</ZipDestination><Pounds>0</Pounds><Ounces>8</Ounces><Container>VARIABLE</Container><Size>REGULAR</Size><Value>34.95</Value><Machinable>FALSE</Machinable></Package>
<Package ID="1"><Service>First Class</Service><FirstClassMailType>PARCEL</FirstClassMailType><ZipOrigination>92065</ZipOrigination><ZipDestination>32570</ZipDestination><Pounds>0</Pounds><Ounces>8</Ounces><Container>VARIABLE</Container><Size>REGULAR</Size><Value>34.95</Value><Machinable>FALSE</Machinable></Package>
<Package ID="2"><Service>MEDIA</Service><ZipOrigination>92065</ZipOrigination><ZipDestination>32570</ZipDestination><Pounds>0</Pounds><Ounces>8</Ounces><Container>VARIABLE</Container><Size>REGULAR</Size><Value>34.95</Value><Machinable>FALSE</Machinable></Package>
<Package ID="3"><Service>PARCEL</Service><ZipOrigination>92065</ZipOrigination><ZipDestination>32570</ZipDestination><Pounds>0</Pounds><Ounces>8</Ounces><Container>VARIABLE</Container><Size>REGULAR</Size><Value>34.95</Value><Machinable>FALSE</Machinable></Package>
<Package ID="4"><Service>PRIORITY COMMERCIAL</Service><ZipOrigination>92065</ZipOrigination><ZipDestination>32570</ZipDestination><Pounds>0</Pounds><Ounces>8</Ounces><Container>VARIABLE</Container><Size>REGULAR</Size><Value>34.95</Value><Machinable>FALSE</Machinable></Package>
</RateV4Request>


RESPONSE FROM USPS:

==================================
CommErr (should be 0): 28 - connect() timed out!

==================================

USPS Country - $order->delivery[country][iso_code_2]: United States $this->usps_countries: US
Domestic Services Selected:
13 Nov 2020, 11:22
#11
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Posts:
13,980
Plugin Contributions:
46

Re: USPS Shipping Module [Support Thread]

That's something to do with your site's server settings, as the request to USPS has (as the debug indicates) timed out.

What version of PHP is in use?

When you view the Admin Tools->Server/Version Information, what values are shown for the site's CURL settings?
25 Nov 2020, 00:19
#12
goodlifetogo avatar

goodlifetogo

New Zenner

Join Date:
Sep 2011
Posts:
1
Plugin Contributions:
0

Re: USPS Shipping Module [Support Thread]

I'm trying to upgrade my usps shipping module...I am not good at this. I followed the instructions..downloaded, unzipped. It said to upload the two files...I found the usps.php in shipping and languages...deeper..but you know that. Now I have no usps shipping module available in my admin page. Sigh.
25 Nov 2020, 07:27
#13
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: USPS Shipping Module [Support Thread]

GoodLifeToGo:

I'm trying to upgrade my usps shipping module...I am not good at this. I followed the instructions..downloaded, unzipped. It said to upload the two files...I found the usps.php in shipping and languages...deeper..but you know that. Now I have no usps shipping module available in my admin page. Sigh.

Chances are that an error is occurring where it "draws" the usps module details to the screen, and that error is also preventing the right-column and the page-footer from showing too. Is that what you're seeing? If so then the error should be documented in your /logs/ directory as a myDebug-adm-xxxxxxxx.log file every time you try to go to that page. What's in that error log file?

And, double-checking ... while the files have the same name, their contents are different, so ... you uploaded each to their corresponding correct directories, overwriting the prior usps.php files, right?
09 Dec 2020, 10:25
#14
wulf359 avatar

wulf359

New Zenner

Join Date:
Feb 2008
Posts:
44
Plugin Contributions:
0

Re: USPS Shipping Module [Support Thread]

lat9:

That's something to do with your site's server settings, as the request to USPS has (as the debug indicates) timed out.

What version of PHP is in use?

When you view the Admin Tools->Server/Version Information, what values are shown for the site's CURL settings?


cURL support enabled
cURL Information 7.19.7
Age 3
Features
AsynchDNS No
CharConv No
Debug No
GSS-Negotiate Yes
IDN Yes
IPv6 Yes
krb4 No
Largefile Yes
libz Yes
NTLM Yes
SPNEGO No
SSL Yes
SSPI No
Protocols tftp, ftp, telnet, dict, ldap, ldaps, http, file, https, ftps, scp, sftp
Host x86_64-redhat-linux-gnu
SSL Version NSS/3.44
ZLib Version 1.2.3
libSSH Version libssh2/1.4.2
16 Dec 2020, 19:52
#15
jodean avatar

jodean

Totally Zenned

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

Re: USPS Shipping Module [Support Thread]

The current USPS - United States Postal Service module for Zen Cart plugin worked when i was running 1.5.7 Now I am on 1.5.7b and USPS is never an shipping option during the checkout process. No errors are displayed and no error logs created. The only customization is SBA.
16 Dec 2020, 20:34
#16
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Posts:
13,980
Plugin Contributions:
46

Re: USPS Shipping Module [Support Thread]

What happens if you enable the USPS debug logging? That will let you (and me) know whether the shipping-method is actually requesting quotes from USPS.

There will be USPS_*.log files generated in your site's /logs sub-directory that contain the request/response information.
16 Dec 2020, 22:49
#17
jodean avatar

jodean

Totally Zenned

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

Re: USPS Shipping Module [Support Thread]

I should have tried the USPS Debug Log first. It gave me clues with what the problem could be and after trying a couple changes in the shipping module set up I got it working. Thanks for your reply.
17 Dec 2020, 02:22
#18
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Posts:
9,707
Plugin Contributions:
6

Re: USPS Shipping Module [Support Thread]

Here's where you help others by letting them know what cured the problem. Nothing worse than finding a thread, following it for a few pages and finding "I fixed it.":P
05 Feb 2021, 18:02
#19
fordlove avatar

fordlove

New Zenner

Join Date:
Jul 2012
Posts:
16
Plugin Contributions:
0

Re: USPS Shipping Module [Support Thread]

I've recently upgraded to v1.5.7, and thought all was working well. Then I noticed I wasn't receiving any international orders. Maybe because of the pandemic I thought? But no, I created a new user with a known good address in Canada. Tried to place an order, and on the shipping page it says: Shipping Method:
This is currently the only shipping method available to use on this order - and it's blank. Nothing to select. I change to a US address, and it works fine. I then upgraded the USPS shipping module, and still the same. I'm only offering flat rate, based on a quantity, since I only sell 1 thing. On domestic I have selected Priority Sm. F/R Box, Priority Md. F/R Box, Priority Lg. F/R Box. For international, I have selected Priority Intl Sm. F/R Box, Priority Intl Md. F/R Box, Priority Intl Lg. F/R Box. All was working prior to upgrading to v1.5.7, and it seems as though domestic is working as it is. Anything in particular I should look at to try to fix this? I have now turned on debug, and see international customers trying to place orders, but are not able to complete them.

Thanks,
Scott
05 Feb 2021, 18:28
#20
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Posts:
13,980
Plugin Contributions:
46

Re: USPS Shipping Module [Support Thread]

fordlove:

I've recently upgraded to v1.5.7, and thought all was working well. Then I noticed I wasn't receiving any international orders. Maybe because of the pandemic I thought? But no, I created a new user with a known good address in Canada. Tried to place an order, and on the shipping page it says: Shipping Method:
This is currently the only shipping method available to use on this order - and it's blank. Nothing to select. I change to a US address, and it works fine. I then upgraded the USPS shipping module, and still the same. I'm only offering flat rate, based on a quantity, since I only sell 1 thing. On domestic I have selected Priority Sm. F/R Box, Priority Md. F/R Box, Priority Lg. F/R Box. For international, I have selected Priority Intl Sm. F/R Box, Priority Intl Md. F/R Box, Priority Intl Lg. F/R Box. All was working prior to upgrading to v1.5.7, and it seems as though domestic is working as it is. Anything in particular I should look at to try to fix this? I have now turned on debug, and see international customers trying to place orders, but are not able to complete them.

Thanks,
Scott

I'm sorry you're having issues with the USPS shipping module. You indicated that you enabled the USPS debug, would you post the contents of one where the international orders have failed? If you do, you could post those contents within the "CODE" tags (the big # in the menu-bar when you're writing your response)?

BTW, which version of 1.5.7 is installed? 1.5.7 (no suffix), 1.5.7a or 1.5.7b?