This calculator shows how you can use custom PHP code in your form.

## Source code for this form:

How many widgets would you like to order? [number* qty] Each widget is $5. If you buy 20 widgets or more, you get a 10% discount. [calculation percent_discount cf7-hide "fn_php(if ($_POST{'qty'} >= 20) { return 10; } else { return 0; })"] [calculate_button "Calculate"] Your total: $ [calculation total precision:2 "5 * qty * (1 - percent_discount / 100)"]