> Should we need to calculate the volumes of each item?

Maybe we should treat each order of each product type as a separate

shipping item, e.g. the example above shipped internationally should be

treated as three shipping orders and priced accordingly (even though

they may all fit in one box).

Has anyone solved this problem in the past?

This makes for a really interesting algorithm; one that I've spent some time

on in the past. If you calculate based on volume alone then you might be

able to decide if you can fit in another area of a larger volume but you

won't be able to determine whether you can snug in the box. For example, a

shipping container might have a volume of 27 sq. meters but the dimensions

might be something like 3 x 3 x 3 meters. The shipping items you are

shipping might be 10 x 1 x 1 meters and won't fix in the shipping container.

Ideally, you'll be using the dimensions of the shipping items and then fit

them together like in the game of tetris. There's many ways to do this and

the way I chose was to create a 3 dimensional matrix and fill the

hypothetical unit with a value to indicate that a shipping item takes up

that space. The size of the matrix will depend on your smallest

calculatable unit (3.8 meters is really 38 centimeters, etc.) so one of your

matrix indices represents 1 centimeter. On another dimension of the

shipping item, perhaps the smallest unit is 1 meter so your other matrix

index represents 1 meter. Of course, the matrix can be huge but like I

said, there might be better ways to do this.

In the end, you can't use volume or dimensions alone to run an abstract

calculation because the math will always work out. You have to somehow be

able to fit them together to see if they will fit in the shipping container

because even though the volume works out and the dimensions seem to, once

you "stack" them together you might not have enough space to fit the

remaining items. Thus, think of it in terms of 3D tetris and you'll do

fine, conceptionally. Another thing is to weed out the largest of the

shipping items, to see if the large of its dimensions exceeds the larger of

the shipping container and then the to the second largest then to the 3rd

largest. If any of them are too large then you automatically know it won't

fit. The other thing is, we keep track of which dimension represents the

"top" of each the shipping item and the shipping container (if there must be

a top such as a television set or something) and that helps to narrow down

the game of tetris, so-to-speak.

Thanks,

Shawn