Skip Navigation

[Resolved] Sorting custom calculation shortcode in views

This support ticket is created 4 years, 3 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 – 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: Asia/Karachi (GMT+05:00)

This topic contains 3 replies, has 2 voices.

Last updated by StanleyT8485 4 years, 3 months ago.

Assisted by: Waqar.

Author
Posts
#1763033

Hi Waqar,
Is there a way to sort a calculated field?

I have created a shortcode called [wpv-calculate] and I am using that to perform the calculation.
Next, I used the calculation in Views. For e.g. [wpv-calculate][types field='price'][/types]/[types field='quantity'][/types][/wpv-calculate]

I want to be sort this calculation in Views in both the back-end and front-end.

Is this possible?

#1763037

Hi Stanley,

As discussed, I've set your next reply, so that you can share your localhost website's duplicator package and the details about the view with the custom shortcode and the sorting.

regards,
Waqar

#1763433

Hi Stanley,

Thank you for sharing the duplicator package.

The way built-in table sorting works, it can function based on the single saved field value and can't recognize the computed final value that is shown in the output.

A better way to include a table sorting functionality, in this case, would be to stop using Toolset View's own sorting feature and use a third-party table sorter script, which doesn't involve, database queries.

You'll find the details about this approach in this support thread, specifically this reply:
https://toolset.com/forums/topic/sorting-nested-tables/page/2/#post-1175110

Note: these are the links that were shared in that reply:
hidden link
hidden link

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1764103

Thanks Waqar for the links. I used tablesorter and it is amazing!