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

Request for Information on Streamlining Product Packing #558

Open
mumairdeveloper opened this issue Sep 9, 2023 · 17 comments
Open

Request for Information on Streamlining Product Packing #558

mumairdeveloper opened this issue Sep 9, 2023 · 17 comments

Comments

@mumairdeveloper
Copy link

Hello,

Thank you for providing this source class. I am using it for packing large pallets and small boxes. Please let me know if there is a way to pack all the products into a single box. I understand that I may have multiple products and multiple boxes, but I would like to select a single box type and, if necessary, repeat the quantity for this box due to having multiple products.

Thank you

@dvdoug
Copy link
Owner

dvdoug commented Sep 17, 2023

If you wish to only use a single type of box even if multiple of that box are required, then you'll need to make multiple invocations to the library with a single box type each time

@mumairdeveloper
Copy link
Author

Hi,

I comprehend the method of making multiple calls to the library, each time using a single box type. I have one final question: Are there any options or flags available to pack items in multiple small boxes, or to efficiently pack small items into the fewest large boxes possible?

Thank you

@mumairdeveloper
Copy link
Author

Hi,

I'd like to pack the products in the smallest box possible. It's not an issue if the packing is done in one large suitable box.

Thank you.

@dvdoug
Copy link
Owner

dvdoug commented Nov 5, 2023

By default, BoxPacker will use the smallest number of boxes. You can change this however if you want

https://boxpacker.io/en/stable/sortation.html#choosing-between-permutations

@mumairdeveloper
Copy link
Author

Hi,

Apologies for reiterating, but I need to clarify my request. I'm looking for a method to consolidate all items into a single box, even if multiple items or boxes are involved. I prefer that all items be packed into a best-fit single box. If this isn't feasible and there's no option for a best-fit single box, please provide an error or an empty response.

Thank You

@mumairdeveloper
Copy link
Author

Hi dvdoug,

I appreciate your assistance with my previous inquiries. I'm seeking guidance on a method to pack all items into a single box, even if there are multiple items or boxes involved. Your help on this matter is highly valuable.

Thank you.

@dvdoug
Copy link
Owner

dvdoug commented Nov 12, 2023

Something like this (untested)

$packedBoxes = $packer->pack();

if ($packedBoxes->count() === 1) {
  return $packedBoxes; // only 1 box, is best fit
} else {
  $possibleSingleBoxSolutions = [];
  foreach ($packedBoxes as $packedBox) {
    $singleBoxPacker = new Packer();
    $singleBoxPacker->addBox($packedBox->getBox());
    $singleBoxPacker->setItems($itemList);
    $possibleSingleBoxSolutions[] = $packer->pack();
  }

  // your logic here to decide which one to use
  $chosenSingleBoxSolution = $possibleSingleBoxSolutions[0];

  return $chosenSingleBoxSolution;
}

@mumairdeveloper
Copy link
Author

Hi,

Thank you so much for your response. I already have this code. I was wondering if you have set any flag for this type of functionality in the API. Okay, if I am going to use the same code, do you agree that it will pack the smallest best-fit single box, even if there are larger boxes also listed? That is the last thing.

Thank you.

@dvdoug
Copy link
Owner

dvdoug commented Nov 12, 2023

Yes, in the scenario where all items fit into a 1 box, ->pack() will return the smallest possible such box

@mumairdeveloper
Copy link
Author

Hi,

You are correct; perhaps that solution won't work. I have another solution: if I sort the list of boxes in ascending order and then check each box one by one from smallest to largest. Could you provide me with an example of this?

Thank you

@dvdoug
Copy link
Owner

dvdoug commented Nov 19, 2023

You are correct; perhaps that solution won't work
I'm not sure what you mean, I agreed with you

@mumairdeveloper
Copy link
Author

Hello,

Sorry for the confusion. I have multiple types of boxes in my array, including medium, random, large, etc. However, they are arranged randomly in the array. I want to sort them all from small to medium and then large. I want to sort them in ascending order based on their size. Thank you.

@dvdoug
Copy link
Owner

dvdoug commented Nov 20, 2023

That will be automatic, see https://github.com/dvdoug/BoxPacker/blob/3.x/src/DefaultBoxSorter.php for the precise implementation

@mumairdeveloper
Copy link
Author

Hi Doug,

I hope this message finds you well. I have been actively exploring solutions to address my current challenges. Unfortunately, the previously suggested solutions have not proven effective in resolving the issue.

I'd like to propose a new idea: the implementation of a virtual box feature. The concept involves passing multiple items, each with its respective quantity, weight, and dimensions. Unlike the previous approach, I would not include a list of boxes in the request. Instead, I'm wondering if your library could generate a single virtual box. This virtual box would consolidate all the specified items, allowing me to obtain shipping rates more efficiently. The ultimate goal is to identify the most cost-effective rates by consolidating all items into a single box.

I'm eager to hear your thoughts on this proposed virtual box solution and would greatly appreciate any insights or solutions you can provide.

Thank you for your continued assistance.

@dvdoug
Copy link
Owner

dvdoug commented Dec 2, 2023

See #189

@mumairdeveloper
Copy link
Author

Doug,

So, there is no solution yet in your library related to this? Perhaps you have added a solution similar to lojadev5 in issue #211 in your library. Please confirm.

I am using those things for shipping rates.

Thank you

@dvdoug
Copy link
Owner

dvdoug commented Dec 4, 2023

No, virtual boxes is complicated for all of the reasons listed in that ticket, there is no built-in support for that at this time

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

No branches or pull requests

2 participants