Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 02-01-2021 20:44:49

Graham
Member
Registered: 09-30-2004
Posts: 990
Website

Adding length check in custom shipping script

I need to add a length check to my custom shipping script.

According to the comments in the code I have at the moment, there's an array called "packages"

// | packages      => An array containing all packages with
// |                  each package defined in it's own array
// |                  with keys: length, width, height, weight.

I've tried the code below, but it doesn't seem to be returning a non-zero result and I'm not sure why not

Code:

      

        $item_length = 0;

     $length = 0;
     
     foreach ($packages as $packageid => $package) {if ($package['length'] > $length) {$length = package['length'];}}

     $item_length = $length;

Last edited by Graham (02-01-2021 20:45:19)

Offline

 

#2 02-02-2021 09:05:46

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19871
Website

Re: Adding length check in custom shipping script

Looks good, except iterate over $info['packages'], not $packages.


Nick Hendler

Offline

 

#3 02-02-2021 09:12:57

Graham
Member
Registered: 09-30-2004
Posts: 990
Website

Re: Adding length check in custom shipping script

webmaster wrote:

Looks good, except iterate over $info['packages'], not $packages.

I changed the variables slightly (so I wasn't using "length" in two places) and this seems to work:

Code:

     $item_length = 0;

     foreach ($info['packages'] as $packageid => $package) {if ($package['length'] > $item_length) {$item_length = $package['length'];}}

Last edited by Graham (02-02-2021 12:32:17)

Offline

 

Board footer