Skip Navigation

[Resolved] Front-End Sorting

This support ticket is created 4 years, 10 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 4 years, 10 months ago.

Assisted by: Christian Cox.

Author
Posts
#1475245

I found this conversation from a few years ago:
https://toolset.com/forums/topic/add-the-ajax-sort-by-price/

At the time, there was no option for front-end sorting. Has that changed?

It would be great to offer a select field that lists options like "sort by price asc, sort by price desc, sort by name, sort by publish date", etc.

Thanks

#1475345

Yes, you can add front-end sorting to a View of Products. You can choose different sorting criteria like price, post date, and post title. Sorting by views_woo_price is most performant for prices, but you should be aware that this is a calculated value and you must manage those calculations in Toolset > WooCommerce Views > Products Fields for Parametric Searches.

You can also add direction controls for ASC and DESC sorting. Click "Sorting Controls" above the Search and Pagination panel in the View editor to add and configure front-end sorting controls. If you cannot see Search and Pagination, scroll to the top right corner of the screen in the View editor page and click "Screen Options" to enable the panel.

#1475851

That looks pretty straightforward! There's ALWAYS a way to do it with Toolset....

However, I've got a strange issue. I'm sorting by price, with the price being an ACF number field. It works perfectly, except for ONE item, which is being mis-sorted.

Here's a quick video showing the issue. I'm hoping you might have an idea what's wrong:

hidden link

Thanks

#1479525
Screen Shot 2020-01-26 at 10.26.17 AM.png
Screen Shot 2020-01-26 at 10.27.08 AM.png

Okay my guess is the sorting algorithm isn't set correctly. When you insert sorting controls, you will choose your custom price field first. Then you'll have the option to choose the sorting algorithm. Your options are usually "as a native custom field", "as a string", or "as a number". You want "as a number" in this case. I would delete the sorting controls you currently have in place and insert them again. Let the system generate the appropriate shortcodes for you, and make sure "as a number" is selected in the popup. I'm attaching screenshots here so you can see what I'm talking about. One is the popup where you can choose the sort algorithm, and the other is the resulting shortcodes from my Search and Pagination panel. Let me know if updating the sorting algorithm and recreating the sorting controls does not solve the problem.