Introduction
A calculation formula uses merge tags to bring field values into the calculation. Adding a modifier to a merge tag lets you choose which value is used, such as the price of a product instead of its value, or its quantity.
Without a Modifier
When a merge tag has no modifier, such as {Package:3}, the value used depends on the field:
- Product fields of type Single Product, Drop Down, and Radio Buttons, and Option fields of type Checkboxes, use the price.
- All other fields use their value.
Available Modifiers
| Modifier | Example | Uses |
|---|---|---|
:value | {Package:3:value} | The value of the selected choice instead of its price. |
:price | {Package:3:price} | The price of the selected choice. |
:qty | {Package:3:qty} | The quantity of the product. Pricing fields only. Returns 0 when no quantity is entered. |
:numeric | {Amount:4:numeric} | The value converted to a number, for example 1,200.50 becomes 1200.50. Returns 0 when the field is empty. |
Note: Modifiers that return text and any value that is not a number are calculated as 0.
Using an Input ID
To use a single input of a field, use its input ID instead of a modifier. For example, {Product:1.3} uses the quantity input of a Single Product field.
Examples
Shipping Cost Based on Weight
A Product field of type Drop Down named Package has the choices Small, Medium, and Large, with Show Values enabled and the values set to their weight in kilograms (2, 5, and 10). To charge 1.50 per kilogram, the calculation uses the value instead of the price:
{Package:3:value} * 1.5
Line Total for a Product
A Product field of type Drop Down named Package has a price for each choice and Quantity enabled. To charge the price of the selected choice for each unit ordered, the calculation multiplies the price by the quantity:
{Package:3:price} * {Package:3:qty}
Things to Know
- A field hidden by conditional logic is calculated as 0.
- Numbers are read using the field’s Number Format setting. See Number Formatting Rules.
- Developers can change a value before it is used in a formula with the gform_merge_tag_value_pre_calculation filter.