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.
Pages: 1
I'm selling some items which are longer than the length that Royal Mail allows for a Small Parcel, so I need to add extra cost if an order will need to go in a Medium parcel.
In the basic supplied code it says:
// | All custom shipping scripts work in the same way. A global // | variable named 'ecom.customship' contains the following PHP // | array. Array keys with value info: // | // | packages => An array containing all packages with // | each package defined in it's own array // | with keys: length, width, height, weight.
I've created a variable $ship_length but how do I set it to the package length?
Also if someone orders multiple items, how do I find the longest one?
Offline
Thanks for the reply, but I'm afraid I don't understand what you mean.
How do I actually find what an item's length is from the $packages array?
Is it just something like $ship_length=$packages(length)?
Offline
$packages is an array, meaning it's a list of packages. To see what's in it, do:
print '<pre>' . print_r($packages,1) . '</pre>';
To loop through it and get the length of the first package:
$length = 0; foreach ($packages as $packageid => $package) {$length = $package['length']; break 1;}
To loop through it and get the length of the longest package:
$length = 0; foreach ($packages as $packageid => $package) {if ($package['length'] > $length) {$length = $package['length'];}}
Offline
Pages: 1