Created
November 9, 2012 18:18
-
-
Save liamzdenek/4047303 to your computer and use it in GitHub Desktop.
product-packing markup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$boxes = array( | |
array( | |
length => 10, // IN | |
width => 10, | |
height => 10, | |
cost => 4, // USD | |
), | |
array( | |
length => 12, | |
height => 1, | |
width => 6, | |
cost => 3, | |
), | |
// but there's like 50 of these | |
); | |
$product = array( | |
length => 4, | |
width => 4, | |
height => 0.1, | |
); | |
$quantity = 135; | |
$boxes_fit = calculate_how_many_fit_in_each_box($boxes); | |
/* | |
it looks like this: | |
$boxes = array | |
( | |
how many fit in the box => array( | |
array( | |
length => 10, // IN | |
width => 10, | |
height => 10, | |
cost => 4, // USD | |
), | |
// more boxes that fit the same number of products will appear here, | |
), | |
how many fit in this box => array( | |
array( | |
length => 12, | |
height => 1, | |
width => 6, | |
cost => 3, | |
) | |
) | |
) | |
*/ | |
$best_fit = create_box_groups($boxes_fit, $quantity); // this is the logic i'm asking about | |
return pick_best_box_config($best_fit); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment