I use the following code to get the combined package width, height and depth.
$packer = new Packer();
$packer->addBox(new TestBox('8x10', 100, 10, 10, 0, 100, 10, 10, 60));
$packer->addBox(new TestBox('Bundle', 75, 15, 15, 0, 75, 15, 15, 30));
$packer->addItem(new TestItem('Item 1', 14, 12, 2, 2, true));
$packer->addItem(new TestItem('Item 2', 14, 12, 2, 2, true));
$packer->addItem(new TestItem('Item 3', 14, 12, 2, 2, true));
$packer->addItem(new TestItem('Item 4', 14, 12, 2, 2, true));
$packer->addItem(new TestItem('Item 5', 14, 12, 2, 2, true));
$packedBoxes = $packer->pack();
echo("These items fitted into " . count($packedBoxes) . " box(es)" . PHP_EOL);
foreach ($packedBoxes as $packedBox) {
$boxType = $packedBox->getBox(); // your own box object, in this case TestBox
echo("{$boxType->getReference()} w: {$packedBox->getUsedWidth()} l: {$packedBox->getUsedLength()} d: {$packedBox->getUsedDepth()}" . PHP_EOL);
echo("The combined weight of this box and the items inside it is {$packedBox->getWeight()} lbs" . PHP_EOL);
echo("The items in this box are:" . PHP_EOL);
$itemsInTheBox = $packedBox->getItems();
foreach ($itemsInTheBox as $item) { // your own item object, in this case TestItem
echo($item->getDescription() . PHP_EOL);
}
echo(PHP_EOL);
}
The correct usedDepth should be 10 in this scenario. Please advice.
I use the following code to get the combined package width, height and depth.
The result is correct except the dimension
These items fitted into 1 box(es)
Bundle w: 12 l: 14 d: 2
The combined weight of this box and the items inside it is 10 lbs
The items in this box are:
The correct usedDepth should be 10 in this scenario. Please advice.