Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong Used Depth #7

Open
serkozk opened this issue Jun 14, 2017 · 1 comment
Open

Wrong Used Depth #7

serkozk opened this issue Jun 14, 2017 · 1 comment

Comments

@serkozk
Copy link

serkozk commented Jun 14, 2017

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

@mdeboer
Copy link
Member

mdeboer commented Jun 15, 2017

That would seem the logical answer but to be sure I'd have to draw it, I can't do it from the top of my head. Currently I have no time to dig in to this unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants