Several sizeof errors

If it doesn't quite fit in the other areas, put it here...
Post Reply
ArtcoInc
Contributor
Posts: 119
Joined: Fri Oct 25, 2019 4:19 pm
Phoenix Version: v1.0.3.0
Has thanked: 86 times
Been thanked: 17 times

Several sizeof errors

Post by ArtcoInc »

I am installing a new USPS shipping module into my old store, and I am receiving several sizeof() errors.

One is in /includes/classes/shipping.php. I have found that I can address the error if I make this edit:

Code: Select all

//            for ($i=0, $n=sizeof($quotes['methods']); $i<$n; $i++) {
            for ($i=0, $n=sizeof((array)$quotes['methods']); $i<$n; $i++) {
The second is in /checkout_shipping.php. I have found that I can address this error if I make this edit:

Code: Select all

//        for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) {
        for ($j=0, $n2=sizeof($quotes[$i]['methods'] ?? []); $j<$n2; $j++) {
Does anyone see a problem with either of these two 'fixes'?

1) Yes, these are 'core' changes. I do not have a problem with that.
2) Yes, the *source* of these problems in the new USPS add-on, and I am only treating the symptoms.
3) Yes, this is an old version of Phoenix (1.0.3.0), and these 'problems' MAY have been addressed in newer versions.

Thanks in advance!

Malcolm

Phoenix 1.0.3.0
PHP 7.4.33


Join The Code Co-op to get access to your library in the Code Co-op Forum
BrockleyJohn
Certified Developer
Posts: 173
Joined: Mon Mar 01, 2021 5:37 pm
Phoenix Version:
Has thanked: 2 times
Been thanked: 30 times

Re: Several sizeof errors

Post by BrockleyJohn »

Yes, early phoenix and frozen don't cope with a module returning the quote structure but with method not set and this will stop it whingeing.

It expects the module just to return false. I've implemented something like your edits for a customer before, along with something to show an error message from the module if one is set (e.g. no rates returned, please check your postcode is correct)

My new USPS module works on your core (by choosing the 234BS version) - for my addon, the distinction is drawn for dialog support in admin (jquery v bootstrap)
ArtcoInc
Contributor
Posts: 119
Joined: Fri Oct 25, 2019 4:19 pm
Phoenix Version: v1.0.3.0
Has thanked: 86 times
Been thanked: 17 times

Re: Several sizeof errors

Post by ArtcoInc »

@BrockleyJohn Thank you!
I purchased your module, and so far, it is working great. A lot more configuration than the old USPS module.

Malcolm
ceitron
Member
Posts: 7
Joined: Thu Jun 27, 2024 7:04 pm
Phoenix Version:

Re: Several sizeof errors

Post by ceitron »

I just purchased the usps module from cartmart.
I have a small issue which I am attempting to resolve.
"Shipping module will not load until API settings are configured. Please install & configure the cartmart_uspsrest module from Modules > Cartmart Addons."
Do I have to edit this module to insert my zip code? I do not see where to add this and normally I do not edit the PHP script.
Hmm, I stuck

Regards,
Steve
ceitron.com/sales
User avatar
burt
Core Team
Posts: 4546
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Several sizeof errors

Post by burt »

Steve, support for paid-for addons is with the addon provider as only the creator (and the buyer) has the code.
@BrockleyJohn
I am not here to build for you.
I am here to build with you. Let's help each other.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply