AnsweredAssumed Answered

Repost: Script help needed to determine shipping boxes needed

Question asked by JasonO'Berry on Jun 24, 2013
Latest reply on Jul 2, 2013 by philmodjunk

Title

Repost: Script help needed to determine shipping boxes needed

Post

Hi,
      
I am in need of some help crafting, what is to me, a complicated calculation. My company ships Art prints in different sized tubes. Depending on the size of the print and the quantity, I need a calc that can determine which box to use, and the final weight. 

               Each of our tubes can hold up to 3 prints. So an easy example, if a customer orders 1, 2, or 3 small prints, the calc should determine that 1 small tube can be used. But if they order 4 then 2 small tubes are required. 

               But if someone orders 1 extra large print and 2 small prints, it should determine that 1 extra large tube can be used.

               It get more complicated if say a customer orders 1 extra large, 1 large, and 3 small prints. In that case I always want to group the larger prints into the largest tube. So the X-large, Large and 1 small print should use 1 extra large tube, and the remaining 2 small prints should use 1 small tube.

               Is this an example of where some recursive function should be used or can this be achieved with standard operations.

               I enter all products in on a line item table and that is where the size field is also. I've also created a boxes table to hold the tube sizes, dimensions, and max quantity.

               Thanks in advance.

                

               UPDATE: I forgot to mention that I have a quantity field that needed to be figured into the script as well.

                

               @Ninja & PhilModJunk

                

               "I've been trying to get your previous examples to work for me but so far unsuccessfully. Mostly due to the quantity field and using a larger tube if it still has space available. I guess I'm not very experienced with looping and placing commands in the right place. I can get the number of the sizes of prints into variable, but I can't figure out how to correctly step through the variables to get the needed tubes with a 3 print maximum. I've put in the work, I just can't get the results I need. Your help is appreciated.maybe a more detailed walk through is what I need. Thanks."

                

"This is getting more complicated by the second. I thought I had a working loop but it would not take into account if the max had not been reached for a larger tube, when it started working on a smaller tube. It would just create another tube and start using the smallest size tube that would accomodate that print, leaving the previous tube with remaining space.

               Please Help. I would post what I came up with, but i think it's was too complicated and probably not a good starting point for help. So back to the chalkboard."

      

Outcomes