Skip Navigation

[Resolved] Front-end calculation field needed

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to create a field in a CRED form that will display a calculated value based on other form field values.

Solution: CRED does not currently offer a JavaScript API for performing calculations on demand in the front-end form. The cred_save_data API can be used to perform calculations when the form is submitted, but not during the form entry process.

This support ticket is created 6 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 6 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#630500

I am trying to build a Cred submission form with a calculation field, I have not decided if I need to use the custom post type or Woocommerce product post type, so you may need to give me two pieces of codes, one for the custom post type, another one for Woocommerce product post type if there are different for that.
1. Custom numeric field price, field: Price, the slug of the field should be wpcf-price;
2. the results of calculation based on another radio field, A, B, C,; A,10% off, B 15% off, C. 20%; (I have not decided if I need to set the result based on another conditional field or just a fixed value, please give me another fixed as well).
for example,
1. On the Cred form, a user enters the price as 100, and choose the radio field, A, display a net price as 90;
2. On the other hand, a user enters the price as 100, Just display a net price as 90;(this situation is that I may want to set a fixed value as a multiplicator );
3: I need to display the result in front-end and only is visible to the specific user, can I use Access plugin with shortcode? but I guess it cannot be displayed by type plugin directly, please also teach me how to do that.

I have read this thread https://toolset.com/forums/topic/calculate-value-of-a-custom-field-based-on-other-custom-fields-values/ , but I am not able to clarify what the post says.

Thank you so much for your great help!

#630588

The other ticket describes how to use the CRED API to calculate values after the form is submitted. The calculated values do not appear while the User is filling in the form. The calculated values only appear on the post being created. Based on your description, it sounds like you are looking for a way to calculate values on the front-end before the form is submitted. Unfortunately CRED does not offer that feature and it would require custom JavaScript code.