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.
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
$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
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:
$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