Plan your formula from the scratch
We recommend you to make tests in excel, Google Docs/Drive or other spreadsheet program.
Write it in simple terms like (A + B) * C, nobody like you knows how your business works.
Add required options in OpenCart, selecting where to use a combo, radio, checkbox or a textbox.

Formulas can be written in several lines for better reading
Remember that CFO uses PHP so take care of the syntax and end each line with “;”

$FinalPrice = ({1V} + {2V}) * $Price;
$FinalPrice = $FinalPrice + {3P} + {4P};

You can use your own variables to clarify your formula
If you are using your own variables take care not using reserverd words, the better way to avoid it is to use a prefix like “$my”, for example “$myTest”.
PHP is case sensitive for variables, functions, etc…

$myTest = ({1V} + {2V}) * $Price;
$myTest = $myTest+ {3P} + {4P};
$FinalPrice = $myTest;

Also you can use comments

// Width and Height are expressed in meters for this calculation
$myTest = ({1V} + {2V}) * $Price;
$myTest = $myTest+ {3P} + {4P};

// Here we have the final price
$FinalPrice = $myTest;

Of course you can use conditionals

// First calculate square meters (Width x Height in our example)
$SquareMeters = {1V} * {2V};

// Use some tmp variable for a hypothetical extra cost
$ExtraCost = 0;
if($SquareMeters>10) {
     // Oh it's really big, this will add $5 to the final price
    $ExtraCost = 5; 
} 

$FinalPrice = ($SquareMeters * $Price) + $ExtraCost;