Tell us what you are trying to do?
I have a site with CPT-s called 'Classes' and 'Guests' in many-to-many relationship. I have an intermediary post type 'guests-attended-class' with a custom field of 'payment'. I already have a content template for Guests including a view that shows all the payments made by the specific Guest. I would like to display the sum of payments on the same content template, but I didn't find a way to do that.
What is the link to your site?
It's on localhost yet.
Thank you for your help!
Attila
Hello and thank you for contacting the Toolset support.
You will need a custom code to calculate this sum. Check the following snippets as examples:
- hidden link
- hidden link
The code may be formatted in an incorrect way, but it will give you an idea about it.
You can also query the intermediary posts using the Toolset Relationship API and calculate the sum. https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts
Check some previous similar tickets:
- https://toolset.com/forums/topic/how-to-get-sum-of-custom-field/#post-247976
- https://toolset.com/forums/topic/custom-fields-calculations-sum-total-of-two-fields/
More similar tickets in this scoped Google search: hidden link
I hope this helps. Let me know if you have any questions.
Thank you, I found some valuable information in the links that help to solve the problem.