lat9 / usps

USPS shipping module for Zen Cart
Other
1 stars 3 forks source link

Correct PHP warning when no quote is returned (e.g. unsupported country or oversize) #19

Closed lat9 closed 2 years ago

lat9 commented 2 years ago

... as reported in this Zen Cart support-thread posting: image

proseLA commented 2 years ago

i'm encountering this error, and i thought i would help out on some troubleshooting. despite what it says in the posting, the error is happening on line 489.

but i think the problem is here: https://github.com/lat9/usps/blob/c83888fb412c33dd7897e64c9e33c8a41f2e4b30/includes/modules/shipping/usps.php#L393-L429

if we were to look at $uspsQuote right after line 393 when an error occurs, we would see the following:

image

and none of the error checking accounts for any of that. so we bypass all of the errors, and we get to line 428, and we think all is good. when it is not.

in my limited testing, the quote always comes back in that package array.

if you wanted to preserve all of that legacy tests for the return quotes, fine. but i think this problems can be soved by adding another test after 426 as such:

        if (isset($uspsQuote['Package']['Error'])) {
            $this->quotes = [
                'module' => $this->title,
                'error' => $uspsQuote['Package']['Error']['Description'] ?? 'No Description Found.',
            ];
            return $this->quotes;
        }

i'm not sure how well that version of OPC plays with this return, as i'm getting some other errors, but alas that is another thread.

best.

lat9 commented 2 years ago

Noting that the correction will "play well' with the base Zen Cart checkout_shipping page as well with OPC's checkout_one page, but the shipping_estimator will continue to have issues.

I'll be submitting a base Zen Cart issue to deal with that.