How it works
As we mention before, CFO uses PHP syntax in order to access to variables, options and values of your products.
It will allow you to override the way that OpenCart calculates product price, starting to use your formula logic.
You will be able to access details in product form and those values entered by the customers when they push “add to cart” button.

Product details configured in each product form
Can be accessed and used in your formulas just using their correspondent variables as follows, and they are very obvious:
$Price $Weight $ProductQuantity $ProductMinimumQuantity $ProductLength $ProductWidth $ProductHeight
NOTE: OpenCart uses ProductQuantity refered to stock, so we have added $ProductStock which is the same but easier to understand, so you can use both.

Option Values
Are related to values entered and selected by the customers, filling each option of your product.
Let’s say we are accessing an option with id 1
{1} or {1V} Value entered by the customer or Value of the selected option.
{1P} Price part of selected option (only in select, radio and checkboxes)
{1S} Points part of selected option (only in select, radio and checkboxes)
{1W} Weight part of selected option (only in select, radio and checkboxes)
{1T} Text part of selected option (use it with care because of language changes).
$Quantity Number selected by customer when filling the product details to purchase.

Assigning final values
You cannot assign any value to those variables we have explained above.
To assign final values you have to use those variables as follows, and they are very obvious too:
$FinalQuantity $FinalWeight $FinalLength $FinalWidth $FinalHeight
And:
$FinalPrice That is the last step in your formula, this varible will store your final calculation and it will be the fial price of the product.

Use them in your formula like this

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

Best practices
It’s very recommendable to store each option_id into your own variables so you can read your formula better, as you can see in the next demo.
You can create as many variables as you need, just a name preceded by “$”. The only care is not to use reserved words (Take a look at PHP syntax)

$meCustomerWidth = {13V};

You can visit this demo in our Demo Store

More about using Combos or Select boxes, Radios or Checkboxes
These options have three parts that can be accessed by CFO (Lets say we keep on using option id 42)

Value part: accessed with V like {42V}
When used in a combo (select) or a radiobutton, will return selected option text converted to number. (See how CFO converts text to numbers)
When used in a checkbox will return the number of checked boxes in that option.

You can configure your option texts as, for example: 20 cm, 10 mm or 15 meters and CFO will automatically convert to meters.
If you use, for example: 50 x 70 cm, each value will be converted to meters and then multiplied, so it’s very useful to configure custom dimensions.
In this manual you will find a way to convert to and from other units like feet, inches, yards, kilometers.

Price part: accessed with P like {42P}
It will return the configured price in the selected option.

Text part: accessed with T like {42T}
It will return the text of the selected option of combos, radio buttons or checkboxes.

Using Textboxes
It will let the user enter all kind of values, texts or numbers so it’s important to make all checkings in order to obtain regular values for your formula.
You will be able to perform this checkings thanks to CHK extension (find howto here) manual.

Value part: accessed with V like {42V}
Use entered value as a number.
Customers can enter for example 6, 20 cm, 10 mm or 15 meters and CFO will automatically convert to meters.
The recommended behavior for a textbox is to limit a range of valid numbers, this way you will not find unexpected chars in your formula (find howto here)

Text part: accessed with T like {42T}
It will return the text as entered by customer.