Skip Navigation

[Resolved] Make the sum of custom fields in different columns

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

Problem:

The issue here is that the user wanted to sum their table columns
Solution:

This is not something that can be done with toolset.
I would suggest taking a look at the link below as this should be able to help you.
https://www.studentstutorial.com/jquery/jquery-sum-total-for-column

This support ticket is created 5 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by Pat 5 years, 7 months ago.

Assisted by: Shane.

Author
Posts
#1256801

Pat

Hello,

I have a Views that display "inscription" posts.
For each post, I have the price paid (numeric field) and the type of inscription (radio field with different potential values : adhesion, sorties, conférences).

So, in my Views, I have a table that display the price paid, but depending of the type of inscription in the specific column (relative of the inscription type).

So, the result is like this :

Inscription Adhésion Sorties Conférences
1 20
2 25
3 10

and so on.
Now, I want to add in the bottom of the table, the sum of each column. I have found this thread (https://toolset.com/forums/topic/sum-quantities-of-the-column/) that works fine if we have only one column to sum.

Here, I want to have the sum of each column independently, knowing that the custom field that is displayed is always the same (I'm just using conditional output to display it at the right column).

How can I get this sum in the bottom of each column?

Regards
Pat

#1257303

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pat,

Thank you for getting in touch.

I can let you know that this is going to require custom coding which is out of our forum scope.

However if you let me see an example of the table then I can point you in the right direction for this.

Thanks,
Shane

#1257317

Pat

Hi Shane,

Thanks for taking care.
Here is my Views :
Loop editor :

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<table width="100%" class="table-striped table-bordered table-hover table-sm">
		<thead>
			<tr>

              <th>CA</th>
              <th>NC</th>
              <th>AT</th>
              <th>LG</th>
              <th>IN</th>
              <th>SO</th>
              <th>CO</th>
              <th>AD</th>
			</tr>
		</thead>
		<tbody class="wpv-loop js-wpv-loop">
		<wpv-loop>
			<tr>
				[wpv-post-body view_template="loop-item-in-backoffice-etat-inscriptions-et-paiements"]
			</tr>
		</wpv-loop>
		</tbody>
	</table>
	<!-- wpv-loop-end -->

<table width="100%" class="table-striped table-bordered table-hover table-sm">
		<thead>
			<tr>
              <th>CA</th>
              <th>NC</th>
              <th>AT</th>
              <th>LG</th>
              <th>IN</th>
              <th>SO</th>
              <th>CO</th>
              <th>AD</th>
			</tr>
		</thead>
<tbody>
			<tr>
              <td>[count_numeric_cf field="wpcf-tarif-du-produit-achete" action="sum"]</td>
              <td>[count_numeric_cf field="wpcf-tarif-du-produit-achete" action="sum"]</td>
              <td>[count_numeric_cf field="wpcf-tarif-du-produit-achete" action="sum"]</td>
              <td>[count_numeric_cf field="wpcf-tarif-du-produit-achete" action="sum"]</td>
			</tr>

		</tbody>
	</table>


	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

And loop item :

<td style="text-align:right;">[wpv-conditional if="( $(wpcf-type-d-evenement) eq 'Ateliers' )"][types field="tarif-du-produit-achete"][/types][count_numeric_cf field="wpcf-tarif-du-produit-achete" action="add"][/wpv-conditional]</td>
<td style="text-align:right;">[wpv-conditional if="( $(wpcf-type-d-evenement) eq 'Langues' )"][types field="tarif-du-produit-achete"][/types][count_numeric_cf field="wpcf-tarif-du-produit-achete" action="add"][/wpv-conditional]</td>
<td style="text-align:right;">[wpv-conditional if="( $(wpcf-type-d-evenement) eq 'Informatique' )"][types field="tarif-du-produit-achete"][/types][count_numeric_cf field="wpcf-tarif-du-produit-achete" action="add"][/wpv-conditional]</td>
<td style="text-align:right;">[wpv-conditional if="( $(wpcf-type-d-evenement) eq 'Sorties' )"][types field="tarif-du-produit-achete"][/types][count_numeric_cf field="wpcf-tarif-du-produit-achete" action="add"][/wpv-conditional]</td>
<td style="text-align:right;">[wpv-conditional if="( $(wpcf-type-d-evenement) eq 'Conférences' )"][types field="tarif-du-produit-achete"][/types][count_numeric_cf field="wpcf-tarif-du-produit-achete" action="add"][/wpv-conditional]</td>
<td style="text-align:right;">[wpv-conditional if="( $(wpcf-type-d-evenement) eq 'Adhésion' )"][types field="tarif-du-produit-achete"][/types][count_numeric_cf field="wpcf-tarif-du-produit-achete" action="add"][/wpv-conditional]</td>

Regards
Pat

#1257551

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pat,

I would suggest taking a look at the link below as this should be able to help you.
hidden link

Thanks,
Shane

#1266467

Pat

Hi Shane,

The link you proposed was answering 100% of my concern.
Many thanks
Pat