Hello Christian,
Thank you so much for providing me detailed instructions on how to set up calculations fields.
I think that Toolset should seriously introduce an easier way to add calculations by the way.
To be honest, I found easier to use the old Views compared to Toolset Blocks, I needed a table to show few columns and a total calculation and the loop wizard + some hand coding by myself allowed to create the table I wanted.
Just to give you an idea this is wanted I wanted to achieve:
hidden link
Last question how can I get in the total field the commas for thousand value? Eg. instead of 1000, this one? 1,000.
Look forward to your reply
Best wishes
Again, there is no simple solution for calculating and formatting numbers like this built-in to Toolset. You can try adding another shortcode and wrapping the previous shortcode with this formatting shortcode:
https://toolset.com/forums/topic/table-sorting-numbers-and-currency-not-working-properly/#post-616384
Hi Christian,
Sorry for the late reply.
The solution you gave me works for the single entry, each amount in the custom field gets the comma, thank you.
But still, I am getting the total from Total £[show-total][/show-total] without the comma.
Any chance you can provide me with a workaround?
Best wishes
Okay I'm not clear from your response - did you try wrapping show total in the formatting shortcode, like this?
Total £[ts_format_number][show-total][/show-total][/ts_format_number]
I did,
But I get total "0" so is not working.
Cannot show the actual table since is sensitive data.
Cheers
Okay please modify the show-total shortcode from the other solution. Here is the updated version:
function show_total_shortcode( $atts, $content ) {
global $total;
$atts = shortcode_atts( array(
'decimals' => 0
), $atts );
$totalNew = $total;
$total = 0;
return number_format($totalNew, (int) $atts['decimals'] );
}
add_shortcode('show-total', 'show_total_shortcode');
Now you should be able to remove the format number shortcode wrapping the show-total shortcode, and display the formatted number with any number of decimal places. Here's an updated usage example:
Total £[show-total decimals="2"][/show-total]
Note that the "2" here sets the number of decimals in the rendered output. If this isn't working as expected, please copy + paste the code from your View's loop so I can see how you are using the add-to-total shortcode and how you are displaying each number in the loop. Thanks!