Skip Navigation

[Résolu] Summing the values in number fields in filtered View

This support ticket is created Il y a 4 années et 9 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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: Asia/Kolkata (GMT+05:30)

This topic contains 10 réponses, has 2 voix.

Last updated by Kenneth Horn Il y a 4 années et 9 mois.

Assisted by: Minesh.

Auteur
Publications
#1292793

I am using Divi and WordPress most recent versions.

I would like to sum the values of an single field in a View loop targeting a custom post type (Ingredients) that are filtered to display the cpt posts that are related to the WordPress Post in which the View is shown.

I've attempted to register the two custom plug-ins displayed in this KB article:
hidden link

I registered them as two separate plugins in Toolset Settings, one with the slug "add-to-total" (.php) and one with "show-total" (.php). I have not registered these in functions.php. I attempted that to see if that was potentially the problem and got a parsing error.

Here is my code in the view:
<!-- wpv-loop-start -->
<wpv-loop>
[types field="carbohydrates-ing" output="raw"][/types]
[add-to-total]
[types field="carbohydrates-ing" output="raw"][/types]
[/add-to-total]
</wpv-loop>
<!-- wpv-loop-end -->
[show-total]

When I display the View front-end I get the following output:
7 [add-to-total] 7 [/add-to-total] 6 [add-to-total] 6 [/add-to-total] 0.0 [add-to-total] 0.0 [/add-to-total] 3.7 [add-to-total] 3.7 [/add-to-total] 63 [add-to-total] 63 [/add-to-total] [show-total]

As you can see, the View is displaying the values of the fields in the filtered view but the shortcodes that sum the fields and display the total do not appear to be functioning.

What am I doing wrong?

#1292811

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share problem URL where you added the view and access details so I can check what going wrong there.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1292813

Doh! I had a Homer Simpson moment.
I had not activated the Plugins in Toolset Settings. I am now correctly displaying each value of the field for each related post and it the plug-in is correctly displaying the product of the five values. Here is how that View displays in the Post:
7 6 0.0 3.7 63 79.7
I note that 79.7 is the total of the five fields displayed.
I merely want to display the Total (i.e. the 79.7). How do I target the result of the "show-total" plug-in only on the front-end in the Post?

#1292819

The page to view front-end is: hidden link
You will see the View displayed bottom-left in a single white line below the far-left image of the four displayed images.

#1292823

Once you respond to my supplement I will proceed in the manner you suggest. Thanks.

#1292825

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please remove the [types field="carbohydrates-ing" output="raw"][/types] shortcode from your code that is added just before the [add-to-total] shortcode and save your view and check.

#1292841

When I do that is displays the five fields and then a zero for the show-total output.

#1292843

Possibly some way to use a nested view and merely have the show-total output in the parent view?

#1292845

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Upps. I need to check then. Can you please share access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1292885

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now. As I said in my previous reply I deleted this shortcode: [types field="carbohydrates-ing" output="raw"][/types]
As you can see with your view now:
=> hidden link

It displays 79.7 only on the page:
=> hidden link

#1292943

Minesh: Thanks a million. I had removed the other occurrence of that field, not the one BEFORE the shortcode. My apologies.
Looks great. I'll send you post card from the French Riviera once I'm a millionaire. 🙂

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