Page::calculate($formula[,$decimals])
Version 3.8
Calculate given formula
Version 3.8
Calculate given formula
Calculate given formula and return result. Fieldnames are replaced with fields Field::getNumber() -value.
Note about field order Calculation does not work, if calculation has a fieldname that contains a part of other fieldname which is after it.
Counts wrong:
'price * price_multiplier' --> '10*10_multiplier' --> '100'
Counts correctly:
'price_multiplier * price' --> '1.2*10' --> '12'
Float
Count total from amount and price
$total $Order_row->calculate('amount * price');
Use subfield data: Count total from amount and product price.
$total = $Order_row->calculate('amount * product.price');
Use subrows sum:
$total = $Order->calculate('delivery_cost + [order_row: amount * product_price]');
Use of parenthesis:
$total = $Order->calculate('total * (100 - discount_percent) / 100 ');