Skip Navigation

[Resolved] Sort function not working with WooCommerce price

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

Problem: Front-end sorting by the WooCommerce Price field does not seem to be working effectively.

Solution: Our developers are working on a solution to this problem. In the meantime, you may adjust the field type for the views_woo_price field in Post Field Control to be "Number".

This support ticket is created 4 years, 2 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 7 replies, has 2 voices.

Last updated by Christian Cox 4 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#1860085

Tell us what you are trying to do? Add a sort by price to a page

The problem is at hidden link

I see in the url it gives ?wpv_view_count=26043&wpv_sort_orderby=field-views_woo_price&wpv_sort_order=asc&wpv_sort_orderby_as=string

If I change that to wpv_sort_orderby_as=numeric it works.But I don't know how to make that happen.

#1860617

Hi, I see the issue you are describing and I'm asking my 2nd tier team for some additional feedback. I see there is no way to modify the sorting algorithm in the Block Editor configurations for the Sorting block, and I'm asking for the best workaround. Please stand by and I will give you an update when I have some additional information.

#1861501

I have been informed by our developers that there is a feature pending for Blocks that will allow you to choose the sorting algorithm for each Sorting block. Right now, the algorithm is "alphabetic" by default, but that does not allow you to sort on the front-end by price as a number. The new feature will allow you to choose a numeric sort, which will accurately sort by price as a number. I'll be glad to keep you updated here in this ticket as I learn more about this new feature development schedule.

#1861767

Can they give any indication of timescale? It's a fairly important failing. In the meantime is there perhaps a function that can implemented?

#1861777

I have no idea of the timescale yet, beyond the current release (today's releases) those priorities have not been established. In the meantime, the only workaround I know of is to go to Toolset > Custom Fields and scroll down to click the Post Field Control button. Then you can find the views_woo_price field and change that field type to "number". That should solve the problem you described, but may impact other areas where price is sorted alphabetically. Therefore, use this workaround with caution.

#1861903

Yep! That fixed it. I'll check for side-effects but really I can't think of a case where I will wan to use price as a string (famous last words).
Best wishes,
Lal

#1861915

My issue is resolved now. Thank you!

#1879435

Quick update - the numeric sorting option for numeric field filters like Price will included in the upcoming Blocks 1.4 / Views 3.4 releases.