In this example we are going to sell tiles asking to the customer the size of floor, then we are going to translate to required boxes.
We are going to use the function CFO_SetOptionValue to add some texts to the product after it’s added to the cart, in order to clarify the purchase.

We have a product with three options “Floor Width” and “Floor Height”, and a text option called “Purchase details” with a special trick that hides this option in the product form.
To hide a textbox, set it up with “*CFOHideOption*” as initial value, you can login as admin in our store to see how it’s done (demo / demo)
Then we are going to use this hidden field to add details of the purchase.

Testing the product in our demo store
Take a look at the formula, the key is at the end, below “Making up Texts”
Then try to add to cart with sample values, let’s say 250 x 500 cm.
See in the cart how we have added “cm” to each size value and a text clarifying the number of boxes we are going to send.

Read about Rounding your calculations and CFO_SetOptionValue

// Get entered sizes in centimeters
$floorWidth = {22};
$floorHeight = {23};

// Our sample Tiles are 15 x 15 centimeters
$oneTileWidth = 15;
$oneTileHeight = 15;

// Let's calculate how many tiles are necessary
$tilesCountWidth = $floorWidth / $oneTileWidth;
$tilesCountHeight = $floorHeight / $oneTileHeight;

// We will add 15% to final count
$totalTiles = $tilesCountWidth * $tilesCountHeight;
$totalTiles = $totalTiles + ($totalTiles * 15 / 100);

// Each box has 25 tiles and we do not sell half a box
$tilesInABox = 25;

// Calculate the boxes
$totalBoxes = ceil($totalTiles/$tilesInABox);

// We have stored the price of a box in Price of the product
$FinalPrice = $totalBoxes * $Price;
$FinalWeight = $Weight * $totalBoxes;

// Making up Texts
CFO_SetOptionValue(22, $floorWidth . " centimeters");
CFO_SetOptionValue(23, $floorHeight . " centimeters");
CFO_SetOptionValue(24, "Sending " . $totalBoxes . " boxes!");

You can visit this demo in our Demo Store