Can I perform mathematical calculation with data from a Number type custom field?
What I would like to do is this:
I have a price data in a Number field.
I have a discount value in another Number field.
I want to perform an operation that will output the discounted price.
Something like this:
[type field="price"][/type] * ([type field="discountrate" id="$discount"][/type]/100)
I know this particular code would never work, but can it be done somehow?
This is no possible with Toolset.
I can below give a example of a Custom ShortCode you can build to achieve such results.
Calculate Custom fields within a calculate ShortCode that acts like the PHP operator $value += $result
Register this 2 ShortCodes:
global $total;
function add_total_shortcode($atts, $content = '') {
global $total;
$total += wpv_do_shortcode($content);
}
add_shortcode('add-to-total', 'add_total_shortcode');
function show_total_shortcode() {
global $total;
$totalNew = $total;
$total = 0;
return $totalNew;
}
add_shortcode('show-total', 'show_total_shortcode');
Register those ShortCodes in Views > Settings > Compatibility > 3rd Party ShortCodes
Use the ShortCodes in a View as this:
<wpv-loop>
[add-to-total]
[/add-to-total]
</wpv-loop>
[show-total]
More info here:
https://toolset.com/forums/topic/nested-view-with-conditional-sums/
It seems -unfortunately- that for now you need custom programming work 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.