Skip Navigation

[Resolved] Fill Custom Field with Calculation Based Upon Another Custom Field

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

Problem:
Does Toolset provide any methods to perform calculations?

Solution:
No.
It is possible with several custom code approaches, but those are not supported.

Toolset itself does natively not provide any calcualation method.

This support ticket is created 7 years, 7 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 2 replies, has 2 voices.

Last updated by jonE-2 7 years, 7 months ago.

Assisted by: Beda.

Author
Posts
#429879

I would like the Trade Value field to be filled in based upon 70% of the Appraised Value field. Based upon what I have read, I haven't accomplished what I need. JS and writing functions is not my strong suit. Could someone walk me through this?

I have read through the following threads:
https://toolset.com/forums/topic/cred-calculation-fields-with-javascript/
https://toolset.com/forums/topic/create-cred-form-with-read-only-and-and-calculated-fields/
https://toolset.com/forums/topic/calculating-types-custom-fields-and-display-in-html-container/

Here is the CRED form I am using:

[credform class='cred-form cred-keep-original']

<!--[cred_field field='form_messages' value='']-->

<div class="cred-field cred-field-post_title" style="display: none;">
<label class="cred-label">
Money Name
</label>
[cred_field field='post_title' post='money' value='Money for [wpv-post-title]' urlparam='']
</div>

<div class="cred-group cred-group-Listings-Money">
<div class="cred-header" style="display: none;"><h3>Listings Money</h3></div>
<div class="cred-field cred-field-lm-cost-basis">
<label class="cred-label">
Cost Basis
</label>
[cred_field field='lm-cost-basis' post='money' value='' urlparam='']
</div>
<div class="cred-field cred-field-lm-cash">
<label class="cred-label">
Cash
</label>
[cred_field field='lm-cash' post='money' value='' urlparam='']
</div>
<div class="cred-field cred-field-lm-difference">
<label class="cred-label">
Difference
</label>
[cred_field field='lm-difference' post='money' value='' urlparam='']
</div>
<div class="cred-field cred-field-lm-msrp">
<label class="cred-label">
MSRP
</label>
[cred_field field='lm-msrp' post='money' value='' urlparam='']
</div>
<div class="cred-field cred-field-lm-map">
<label class="cred-label">
MAP
</label>
[cred_field field='lm-map' post='money' value='' urlparam='']
</div>
<div class="cred-field cred-field-lm-trade-value">
<label class="cred-label">
Trade Value
</label>
[cred_field field='lm-trade-value' post='money' value='' urlparam='']
</div>
<div class="cred-field cred-field-lm-shipping">
<label class="cred-label">
Shipping
</label>
[cred_field field='lm-shipping' post='money' value='' urlparam='']
</div>
<div class="cred-field cred-field-lm-insurance">
<label class="cred-label">
Insurance
</label>
[cred_field field='lm-insurance' post='money' value='' urlparam='']
</div>
<div class="cred-field cred-field-lm-transaction-expense">
<label class="cred-label">
Transaction Expense
</label>
[cred_field field='lm-transaction-expense' post='money' value='' urlparam='']
</div>
<div class="cred-field cred-field-lm-tax">
<label class="cred-label">
Tax
</label>
[cred_field field='lm-tax' post='money' value='' urlparam='']
</div>
<div class="cred-field cred-field-lm-appraised-value">
<label class="cred-label">
Appraised Value
</label>
[cred_field field='lm-appraised-value' post='money' value='' urlparam='']
</div>
<div class="cred-field cred-field-lm-offer">
<label class="cred-label">
Offer
</label>
[cred_field field='lm-offer' post='money' value='' urlparam='']
</div>
<div class="cred-field cred-field-lm-preparation">
<label class="cred-label">
Preparation
</label>
[cred_field field='lm-preparation' post='money' value='' urlparam='']
</div>
<div class="cred-field cred-field-lm-misc">
<label class="cred-label">
Misc
</label>
[cred_field field='lm-misc' post='money' value='' urlparam='']
</div>
</div>

<div class="cred-group cred-group-parents" style="display: none;">
<div class="cred-field cred-field-_wpcf_belongs_listing_id">
<label class="cred-label">
listing Parent
</label>
[cred_field field='_wpcf_belongs_listing_id' value='[wpv-post-id]']
</div>

</div>

[cred_field field='form_submit' value='Submit' urlparam='']

[/credform]

#430041

Toolset does not provide calculation ShortCodes or code in general.

This is always Custom Code which is beyond the scope of our support.

At this point I would suggest you consider contacting one of our certified partners from this link:
https://toolset.com/consultant/

You will get the custom assistance you need to get on with your project.

You can use JS if you need to calculate this on the fly (before the post is submitted) or PHP, if it's enough to populate the Field after submission.

The Tickets you linked should give enough Examples on how to set this up, and that is all we can do, we can not write the code for you.

As if you want to do it with PHP, you can refer to the CRED API cred_save_data() action, that allows you to get the values from your Fields on submit and update other Fields during this.
https://toolset.com/documentation/user-guides/cred-api/#csd

You can (inside the CRED API Function) apply some native PHP calculation functions.
hidden link

Please let me know if you need more informations on this.

#434678

Not resolved. Will research.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.