Results 1 to 10 of 447

Hybrid View

  1. #1
    Join Date
    Apr 2019
    Posts
    349
    Plugin Contributions
    0

    Default Re: USPS Shipping Module [Support Thread]

    Quote Originally Posted by swguy View Post
    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).
    I noticed the same issues and I spent some time try to fix it. Here is what I found:

    How to trigger this warning:
    1) When you tried to ship this order to a country that USPS cannot ship (like Russia), this warning will be generated (because USPS cannot ship to that country).
    2) If your shopping cart is expensive (like over 10k) or maybe very heavy, and your shipping cart has more than one items, if you want to ship it to non-US country (like France), this warning will be generated. It seems USPS doesn't have a way to ship this order so zen cart cannot get a quote from USPS.

    Here is my fix. I tested and it seems good. I'm not a professional developer, so if you have a better way to improve, please let me know. My USPS module version is 2020-09-24 lat9 Version K11. I checked the latest version, the code in this section is the same.

    Here is the original code near line 487:
    Code:
            if ($this->is_us_shipment) {
                $PackageSize = count($uspsQuote['Package']);
                // if object has no legitimate children, turn it into a firstborn:
                if (isset($uspsQuote['Package']['ZipDestination']) && !isset($uspsQuote['Package'][0]['Postage'])) {
                    $uspsQuote['Package'][] = $uspsQuote['Package'];
                    $PackageSize = 1;
                }
            } else {
                $PackageSize = count($uspsQuote['Package']['Service']);
            }
    Here is my code:
    Code:
            if ($this->is_us_shipment) {
                $PackageSize = count($uspsQuote['Package']);
                // if object has no legitimate children, turn it into a firstborn:
                if (isset($uspsQuote['Package']['ZipDestination']) && !isset($uspsQuote['Package'][0]['Postage'])) {
                    $uspsQuote['Package'][] = $uspsQuote['Package'];
                    $PackageSize = 1;
                }
            } else {
            //    $PackageSize = count($uspsQuote['Package']['Service']);
            if ($uspsQuote['Package']['Service']) {
            $PackageSize = count($uspsQuote['Package']['Service']);
                } 
            }
    Last edited by njcyx; 20 Apr 2022 at 09:32 PM.

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,948
    Plugin Contributions
    96

    Default Re: USPS Shipping Module [Support Thread]

    Thanks for the reports and the detective work! I've opened a tracking issue for the resolution on the USPS shipping modules GitHub repository: https://github.com/lat9/usps/issues/19

  3. #3
    Join Date
    Jun 2016
    Location
    Suffolk VA
    Posts
    618
    Plugin Contributions
    0

    Default Only First Class shipping rates are being displayed

    I posted this in the built in shipping category also, but then realized it probably belonged here.

    All of a sudden, customers are seeing only First Class shipping rates (if a package falls within the weight limit for First Class). If it's heavier than that, they're not seeing USPS rates at all. I've had to take the site down for maintenance to avoid people choosing store pickup for everything. It's acting as though the First Class filter was on, but it is not and never has been.

    I turned on debug, but the post office appears to be returning the rates for all the checked services. They just aren't being displayed to the customer.

    Any ideas? I've had the site down for maintenance for hours now, and I have to get this fixed.

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,948
    Plugin Contributions
    96

    Default Re: Only First Class shipping rates are being displayed

    Quote Originally Posted by HeleneWallis View Post
    I posted this in the built in shipping category also, but then realized it probably belonged here.

    All of a sudden, customers are seeing only First Class shipping rates (if a package falls within the weight limit for First Class). If it's heavier than that, they're not seeing USPS rates at all. I've had to take the site down for maintenance to avoid people choosing store pickup for everything. It's acting as though the First Class filter was on, but it is not and never has been.

    I turned on debug, but the post office appears to be returning the rates for all the checked services. They just aren't being displayed to the customer.

    Any ideas? I've had the site down for maintenance for hours now, and I have to get this fixed.
    I received the USPS log (thanks @HeleneWallis) and will note that the only methods returned are for versions of "Priority Mail". What methods and associated weights are currently configured for the store?

  5. #5
    Join Date
    Jun 2016
    Location
    Suffolk VA
    Posts
    618
    Plugin Contributions
    0

    Default Re: Only First Class shipping rates are being displayed

    Quote Originally Posted by lat9 View Post
    I received the USPS log (thanks @HeleneWallis) and will note that the only methods returned are for versions of "Priority Mail". What methods and associated weights are currently configured for the store?
    All the ones that are showing for Priority Mail, plus First Class and Priority Mail Express. What is really weird, though, is that I'm not getting any log entries now at all. I still have debug turned on, but no log entries are being generated.

    The weights would be 15 ounces for First Class, and anything over that would go in one of the Priority Mail classes.

  6. #6
    Join Date
    Jun 2016
    Location
    Suffolk VA
    Posts
    618
    Plugin Contributions
    0

    Default Re: Only First Class shipping rates are being displayed

    Edit to above--logs are now showing up again. But as you said, only the Priority rates are being returned, even though First Class is enabled.

    One of my customers mentioned that the post office is doing a rate update today. So I guess it's possible that this is actually a PO glitch and not anything in the software.

  7. #7
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,948
    Plugin Contributions
    96

    Default Re: Only First Class shipping rates are being displayed

    The USPS API has done it again; they've changed the branding for the Priority Mail and Priority Mail Express methods from a trademark (TM) to a registered-trademark (RM), which results in a mismatch when the shipping module attempts to locate methods returned.

    An update will be available later today or tomorrow. Thanks, @HeleneWallis, for the notification and your help.

 

 

Similar Threads

  1. Optional Shipping Insurance Module [Support Thread]
    By jettrue in forum Addon Shipping Modules
    Replies: 415
    Last Post: 6 Jul 2026, 02:45 PM
  2. MultiSite Module Support Thread
    By Gerome in forum All Other Contributions/Addons
    Replies: 2246
    Last Post: 29 Dec 2025, 10:13 AM
  3. Replies: 29
    Last Post: 24 Sep 2014, 09:59 PM
  4. Replies: 335
    Last Post: 1 Aug 2013, 08:54 PM
  5. PC Configurator Module [Support Thread]
    By lebrand2006 in forum All Other Contributions/Addons
    Replies: 254
    Last Post: 22 Aug 2012, 03:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg