i4w_math

Usage:

This shortcode is designed to allow you to query a contact field in your Infusionsoft application, perform a simple math operation on it, display/use it and optionally store the result in Infusionsoft.

This shortcode does NOT supports conditional branching with [ELSE_math].

Shortcode nesting is NOT supported.

Parameters:

field The name of the field used to perform the operation.
Required: Yes.
Default: none.
target The name of the field in which to store the results of the operation. If not specified, it defaults to the name provided in “field”. If set to the special value ‘noupdate’ no result will be stored.
Required: No.
Default: none.
operation Specifies the math operation to be performed. Valid operations are: add, sub (subtract), div (divide), mul (multiply), pow (power), mod (modulus), sqr (square root), max (maximum), min (minimum).
value The second operand in the operation to be performed.
Required: Yes, except for sqrt (square root).
Default: none.
round The number of decimal digits to round the result of the operation to. If a positive value is provided the rounding will occur after the decimal point, if a negative value is provided the rounding will occur before the decimal point. Halves are always rounded up. 0 means any value will be rounded to an integer
Required: No.
Default: none.
flip Specifies whether the order of the operands should be switched.
Required: No.
Default: 0 (no).
show Specifies if the result of the operation should be returned to WordPress for display or further use within another shortcode.
Required: No.
Default: 1 (yes).
format Provdes a sprintf-type format string to apply to the result of the operation.
Example Values: %d formats as an integer.
%.2f formats as a floating number with 2 decimal places.
Required: No.
Default: none.

Example:

1. The value of the custom field ‘_wholenumber’ will be queried and 300 will be added to it, storing the result back in the same field. The ‘show’ option indicates that the result of the operation should be returned/displayed.

[i4w_math field='_wholenumber' operation='add' value='300' show='1']

2. The value of the custom field ‘_wholenumber’ will be queried and 300 will be added to it, the result will not be stored back into Infusionsoft. The ‘show’ option indicates that the result of the operation should be returned/displayed.

[i4w_math field='_wholenumber' operation='add' value='300' show='1' target='noupdate']

3. The value of the custom field ‘_decimalnumber’ will be queried and divided by 2, the result will be rounded to two decimal places and stored as a floating number with 2 decimal places back in the same field. The ‘show’ option indicates that the result of the operation should NOT be returned/displayed

[i4w_math field='_decimalnumber' operation='divide' value='2' show='0' round='2' format='%.2f'].

Notes:

The format of how the value is stored within Infusionsoft depends upon the contact field type. Decimal Number, Text and Currency fields will have the data stored by Infusionsoft exactly as calculated by this shortcode. However data stored in a Whole Number field type will be rounded up or down automatically by Infusionsoft upon storing the data.

API:

There is no API function equivalent for this shortcode.