You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I'm testing with our boxes and items I can see that class is suggesting C1 box when I'm going to use 1 as the qty and for 2 pieces it's going to suggest B1 box. I'm sure that everything is fine in this class and it's more like a configuration that I'm missing. so usually in our warehouse for this kind of shipments which we have 2 cap, we will ship it with two separate C1 boxes. now I' wondering that how can I change the settings to suggest two C1 box instead of one B1 box when I'm using 2 as qty.
here is our code :
`<?php
require DIR . '/vendor/autoload.php';
use DVDoug\BoxPacker\Packer;
use DVDoug\BoxPacker\Test\TestBox; // use your own Box implementation
use DVDoug\BoxPacker\Test\TestItem; // use your own Item implementation
$packer = new Packer();
$packer->setMaxBoxesToBalanceWeight(0);
/*
Add choices of box type - in this example the dimensions are passed in directly via constructor,
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 "This box is a {$boxType->getReference()}, it is {$boxType->getOuterWidth()} IN wide, {$boxType->getOuterLength()} IN long and {$boxType->getOuterDepth()} IN high" . PHP_EOL;
echo "The combined weight of this box and the items inside it is {$packedBox->getWeight()}kg" . PHP_EOL;
echo "The items in this box are:" . PHP_EOL;
$packedItems = $packedBox->getItems();
foreach ($packedItems as $packedItem) { // $packedItem->getItem() is your own item object, in this case TestItem
echo $packedItem->getItem()->getDescription() . PHP_EOL;
}
}
`
thank you so much for your kind help.
The text was updated successfully, but these errors were encountered:
First, I just want to point out that the library uses integers for all of its dimension calculations, when you pass in floats PHP will silently truncate them (e.g. although you pass in 9.76, the library actually receives 9 from PHP). I recommend you multiply all of your values by 100 to avoid any future issues.
For your actual question - by default the library optimises for the fewest, smallest boxes it can. It can be configured to choose 2 smaller boxes instead of 1 big one if you want, the best way to do that though depends on why you want to - can you explain your reason a little more?
Hello and thanks for this great class,
As I'm testing with our boxes and items I can see that class is suggesting C1 box when I'm going to use 1 as the qty and for 2 pieces it's going to suggest B1 box. I'm sure that everything is fine in this class and it's more like a configuration that I'm missing. so usually in our warehouse for this kind of shipments which we have 2 cap, we will ship it with two separate C1 boxes. now I' wondering that how can I change the settings to suggest two C1 box instead of one B1 box when I'm using 2 as qty.
here is our code :
`<?php
require DIR . '/vendor/autoload.php';
use DVDoug\BoxPacker\Packer;
use DVDoug\BoxPacker\Test\TestBox; // use your own
Box
implementationuse DVDoug\BoxPacker\Test\TestItem; // use your own
Item
implementation$packer = new Packer();
$packer->setMaxBoxesToBalanceWeight(0);
/*
/
/
$packer->addBox(new TestBox('Le petite box', 300, 300, 10, 10, 296, 296, 8, 1000));
$packer->addBox(new TestBox('Le grande box', 3000, 3000, 100, 100, 2960, 2960, 80, 10000));
*/
//Reliance Boxes
$packer->addBox(new TestBox('7700 Box', 12.12, 12.12, 3.3, 1, 12.12, 12.12, 3.3, 50));
$packer->addBox(new TestBox('7736 Box', 12.48, 12.48, 33.07, 1, 12.48, 12.48, 33.07, 50));
$packer->addBox(new TestBox('7800 Box', 11.63, 11.63, 33.7, 1, 11.63, 11.63, 33.7, 50));
$packer->addBox(new TestBox('7900 Box', 6.87, 6.87, 46.02, 1, 6.87, 6.87, 46.02, 50));
$packer->addBox(new TestBox('B1 Box', 9.76, 9.76, 28.19, 1, 9.76, 9.76, 28.19, 50));
$packer->addBox(new TestBox('B2 Box', 14.88, 14.88, 27.68, 1, 14.88, 14.88, 27.68, 50));
$packer->addBox(new TestBox('B7 Box', 6.61, 6.61, 33.07, 1, 6.61, 6.61, 33.07, 50));
$packer->addBox(new TestBox('C1 Box', 7.38, 7.38, 8.19, 1, 7.38, 7.38, 8.19, 15));
$packer->addBox(new TestBox('C2 Box', 13.39, 13.39, 7.95, 1, 13.39, 13.39, 7.95, 30));
$packer->addBox(new TestBox('C3 Box', 9.88, 9.88, 4.69, 1, 9.88, 9.88, 4.69, 30));
$packer->addBox(new TestBox('C5 Box', 8.39, 8.39, 7.32, 1, 8.39, 8.39, 7.32, 30));
$packer->addBox(new TestBox('Pallet', 48, 48, 48, 62, 48, 48, 48, 1500));
/*
*/
$packer->addItem(new TestItem('cap', 7, 7, 7, 5, true), 2);
$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 "This box is a {$boxType->getReference()}, it is {$boxType->getOuterWidth()} IN wide, {$boxType->getOuterLength()} IN long and {$boxType->getOuterDepth()} IN high" . PHP_EOL;
echo "The combined weight of this box and the items inside it is {$packedBox->getWeight()}kg" . PHP_EOL;
}
`
thank you so much for your kind help.
The text was updated successfully, but these errors were encountered: