Paste the [gravitymath] shortcodes from your pages and GravityView Views. The checker flags the mistakes that make Gravity Math print nothing or the wrong number, then lists the numbers, totals and sub-formulas you repeat, ready to move into Global Variables.
The checker needs JavaScript. The rules it applies are listed below.
What it checks
- Tags. Every
[gravitymath]needs its closing tag. WordPress can’t nest a shortcode inside itself, so an inner formula uses[gravitymath2]or[gravitymath3]. - Attributes.
scopeis form, view, visible or entry; form and view need anid;default_valuemust be a number orskip, or it’s ignored. - Functions. Gravity Math’s functions are lowercase:
round, notROUND. There’s no^or%operator; usepow(x, y)and divide by 100. - Commas. Put a space after each comma between arguments. Gravity Math strips commas out of numbers, so
max(1,2)is read asmax(12). - Merge tags. Aggregate modifiers are
sum,avg,count,minandmax; any other modifier is added up as a sum.{entry_count}takes:visible,:viewor:form. - Arithmetic. Division by a literal zero, unbalanced brackets and two operators in a row.
Why move repeated values into Global Variables
A tax rate typed into twelve shortcodes has to be changed twelve times. Save it once in Global Variables for Gravity Math and write {tax_rate} inside each formula instead. A variable can hold a number, a whole formula or a shortcode, and can use other variables, so a repeated form total becomes one variable too. Change the value once and every formula that uses it follows.
Questions
My formula passes but still prints nothing. Why?
Gravity Math skips a formula when a merge tag comes back empty, unless you set default_value. Add debug="true" to the shortcode while you test to see what it calculated.
Does the checker save or send what I paste?
No. It runs entirely in your browser.
More free tools: the Gravity Forms shortcode builder and our Gravity Forms code snippet library.