Algorithm explanation
Here’s an example for better understanding on how the algorithm works. We defined 3 custom boxes’ types:
- 1x1x1
- 2x2x2
- 5x5x5
The algorithm in such case will look like this:
[ 1, 1, 1, '1' ], // 1 items 1 square = best fit is 1x1x1
[ 2, 1, 1, '2' ], // 1 items 2 square = best fit is 2x2x2
[ 4, 1, 1, '5' ], // 1 items 4 square = best fit is 5x5x5
[ 5, 1, 1, '5' ], // 1 items 5 square = best fit is 5x5x5
[ 0.5, 8, 1, '1' ], // 8 items 0.125 square = best fit is 1x1x1
[ 0.5, 9, 1, '2' ], // 9 items 0.125 square = best fit is 2x2x2
[ 1, 8, 1, '2' ], // 8 items 1 square = best fit is 2x2x2
[ 1, 9, 1, '5' ], // 9 items 1 square = best fit is 5x5x5 (other algorithm could get 2x2x2 + 1x1x1)
[ 1, 125, 1, '5' ], // 125 items 1 square = best fit is 5x5x5
[ 1, 126, 2, '5' ], // 126 items 1 square = best fit is 5x5x5 + 1x1x1 (two packages, exactly one is 5x5x5)
[ 1, 133, 2, '5' ], // 133 items 1 square = best fit is 5x5x5 + 2x2x2 (two packages, exactly one is 5x5x5)
So it will match the best setup to fit as many products as possible into one box based on the product’s dimensions.
Besides providing external dimension of a box, you can also set padding value to accommodate thickness of a box and protective filling. Padding value is subtracted from the external dimensions. Let’s assume that we have a 10x5x5 box and padding set to 1. The algorithm will use 9x4x4 as space available to fill. For more clarity get familiar with the below graphic.

Configuration
Once the Flexible Shipping Box Packing plugin is installed and activated, the following Flexible Shipping Box Packing option should appear at WooCommerce → Settings → Shipping:

Click it to reach the Flexible Shipping Box Packing General Settings screen with the Shipping boxes table:

Adding a new shipping box
In order to define the boxes which you use to ship the ordered products in your shop and which should be also used by the packing algorithm, hit the Add box button in the Shipping boxes table’s footer:

You will be redirected to the individual shipping box configuration screen:

Please mind that all the fields marked with an asterisk sign (*
) are required to be filled in for the shipping box to be fully configured.
Box name – fill in this field with the unique name for easy identification. It will be displayed in the Shipping boxes table.
Length / Width / Height – enter the exact dimensions of the shipping box.
Max weight – enter the maximum weight limit of the shipping box containing the packed products ready to be shipped.
Empty box weight – enter the weight of the empty box itself, which will be included in the Max allowed box weight, e.g., if the Empty box weight is set to 0.25
kg and the Max weight is 5
kg, the total weight of the ordered products can be max 4.75
kg to be packed into this box.
Padding – define the box inner padding, which will be subtracted from the space available to pack the products, e.g., if the box dimensions are 20 x 20 x 20
cm and the box Padding is set to 2
cm, the space available to pack the products will be 18 x 18 x 18
cm.Please mind that the measurement units visible in the screenshot above may vary depending on your current WooCommerce settings configured at WooCommerce → Settings → Products → General → Measurements.
Once all the fields have been filled in here, confirm adding a new shipping box with the Save changes button.
Repeat the same steps to configure the rest of the shipping boxes you use in your shop.
Final result example:

Configuring the Flexible Shipping cost calculation rules for shipping boxes
Flexible Shipping Box Packing WooCommerce plugin adds two new shipping cost calculation conditions to the standard ones available in the Flexible Shipping free and Flexible Shipping PRO version:
- Box type – allows to configure the shipping cost to be based on the type of the boxes used to pack the ordered products for shipping,
- Number of boxes – allows to make the shipping cost dependent on the number of boxes used for shipping the products.
Both of them can be selected the standard way on the Flexible Shipping shipping method’s configuration screen from the When-conditions dropdown list:

and then used to configure the Flexible Shipping shipping cost calculation rules according to your needs, e.g.:

If you do not have any Flexible Shipping shipping methods configured yet, please check our detailed guide on how to add and configure the Flexible Shipping shipping method →