Skip Navigation

[Resolved] Sum of custom field of intermediary posts

This support ticket is created 3 years, 1 month 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
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 2 replies, has 2 voices.

Last updated by attilaT 3 years, 1 month ago.

Assisted by: Jamal.

Author
Posts
#2002761

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

#2002853

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

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.

#2003077

Thank you, I found some valuable information in the links that help to solve the problem.

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