The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

frm-stats total multiply by .15

Labels

This Discussion is public

Notifications

Hello,

I have a frm stats shortcode on a wordpress page like this and it provides a total nicely:

$0

How can I multiply this by .15  to calculate immediately on the same page?? I thought I saw that this needed some PHP but can't for the life of me find the reference.

Thank you!

To calculate anything immediately on a page is best handled with jQuery. PHP requires an Ajax call and a round trip to the server. Can you post a link to the page where you want the calculation and explain which field?

I just noticed that the code was removed. My bad. Let me try that again:

 

[ frm-stats id=391 type=total 534="Sold" decimal=2 thousands_sep="," ]

Hi Victor, thanks for responding. I'm trying to calculate to a page that is separate from where the form is held. Does that matter?

Thanks,

I don't know Nathan. I have to see the output of the shortcode.

https://www.ahappyrealtor.com/

The shortcode outputs formatted text, but it's not formatted with CSS classes or IDs. This means there's no selector for jQuery to grab onto that will allow you to manipulate the text easily. The only selector is a paragraph tag within the entry-content div. The way the output is formatted, you can't isolate a single number.

I also read through the source code for the FrmProStatisticsController that returns the stats requested through the [frm-stats] shortcode. There are no hooks that would allow you to manipulate the output.

The only thing I can think of that might work, and I stress might, is to extend the FrmProStatisticsController class and override the get_stats_from_meta_values() function to create your own calculations. This is advanced PHP coding. If you're not a developer, you may have to hire someone and pay them for a day's work that may not even do what you want in the end. You can expect to pay up to $1,000 USD for work like that, at least, that's what my time would cost.

One alternative is to perform the calculations on the form and store the values in hidden fields. Then use the [frm-stats] shortcode to total the hidden field values. The only drawback I see to this approach is that if you have to change the percentage at a later date to something other than .15, all the values in the hidden field are already calculated,

Not sure if this would work for you but here goes.

Create a single line text field in your form, insert the [frm-stats]code in the default field input at the top of the new field.

Create a new field and in the calculation input insert the key from the field that holds the form stats shortcode and *0.15

Then create a view and add the new key and insert the view shortcode in the page you require.

Is that what you are trying to achieve?

 

Discussion closed.