Skip Navigation

[Résolu] Math Calculations with Custom Fields of related posts inside a 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.

This topic contains 1 réponse, has 1 voix.

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

Auteur
Publications
#1291265

I'm using mathematical calculations native to PHP using the plugin code described in this post: https://toolset.com/forums/topic/math-with-custom-fields-values/
I have a View that pulls custom-fields from a related Parent post. The code works fine inside a view calculating fields in the queried post but I'd like to display the product of a custom-field in the loop and a custom-post in the parent post. It doesn't seem to work. I'm using this code:
[calculate round="2"][types field="cup-weight-ing" output="raw"]*[types field="quantity-1" output="raw" item="$post"][/types][/calculate]
I also tried it with this code: [calculate round="2"][types field="cup-weight-ing" output="raw"]*[types field='quantity-1' output='raw' item='@post-and-ingredient.parent'][/types][/calculate]
It only displays the field in the CPT that's queried in the loop.
Is it possible to compute a product pulling variables from both post types?
Thanks

#1291267

My issue is resolved now. I reversed the order of the two fields, used the field "in the page where the view is shown" times the field in the loop and it worked.
Here is the code that worked: [calculate round="2"][types field='quantity-1' item='$current_page'][/types]*[types field="cup-weight-ing" output="raw"][/calculate]
Thanks!

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