-
Notifications
You must be signed in to change notification settings - Fork 32
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
Support input of container sizes #2
Comments
That's a great idea! I'll have a go at it after I'm back from holiday and have a bit more time to spend. |
Hi mdeboer, Thanks for the great piece of code. I am implementing it in a Drupal Commerce shipping module. I see that you added the ability to specify container size. I see the note about not specifying the height of the container. I find this interesting. If I want to specify a size of a container, the height would be part of that... and then I would just have left over product that doesn't fit. I am just wondering about your decision to calculate the container height on the fly. |
Hi 2ndMile! With all the millions of things going on in my life I forgot about it unfortunately, yet I'm willing to still make the change if you like and it's great to hear that you're implementing it in a Drupal Commerce module! Not sure about the comment about the height, I think this had to do with two "modes", either finding out how many boxes you need (total calculated height / box height) and a mode that just checks whether it fits or not. But I'll look into that and update the documentation on that a bit! If you got any questions, feel free to send me an email ([email protected]) or file a bug report/feature request! |
I looked into the issue and I think it's best to first make the code a bit more OOP, this makes it a lot easier to work with multiple containers. This also allows you to add more data to boxes and containers and extend the whole code a lot easier. Anyway, I'll start working on this in my spare time so bear with me! I'll keep you guys posted 👍 |
Good to hear. I worked on the implementation some last night. Since the height was returned (using my width and length) I compared it with the height of the physical container being packed. This works out well. You saved me a lot of hair pulling. I am using some code from https://drupal.org/sandbox/jhaskins/1873204 to make my module. Most of the shipping modules available for Drupal Commerce are pretty bad when it comes to packing products in containers. Many of them have their own packing algorithm built-in and none of them are good. Joe's idea (the author of the Commerce module) of separating the packing logic from the rate retrieval makes sense on many levels. I am trying to contact him to see if he wants to implement your class. If not, I will go out on my own and try to get this into some useable form for the community. |
Awesome that's great! I'll make another branch with unstable course for testing soon :) Update: I decided not to get in to branching but I tagged this initial release as v1.0 and created a milestone for this task for v2.0 which will be just here in the master branch. |
Happy Christmas by the way! |
Merry Christmas to you too! |
I worked on the code making it more OOP and easy to develop, first few commits should come soon. Got some other projects that require my attention as well :) |
hey mdeboer - any chance you implemented this? I don't care if it's rough code - would really love it if you have it laying around! |
Hi guys, However, when we have several containers, we have a confusion (fuzzy) when choose which containers has the highest priority to pack first. |
This is a simple, albeit BRUTE, way to achieve this: https://gist.github.com/tharmann/f1fd9aa1c5d24fe359491cd49b0eba6f What the code does is basically break a list of items into smaller and smaller chunks until everything fits in a box/container. It has some limitations...example, if the there are adjacent items in the list that will always only fit into a container by themselves...the whole order gets split into one item per box. The good thing is that an optimal box is still found for each item. I will try to improve this functionality in the future...but for for now, the code outputs something like this: |
If you extend this script to also support an array of possible container sizes, and then finding the combination that fits all boxes, it would be even more perfect :)
Example:
The text was updated successfully, but these errors were encountered: