Skip Navigation

[Fixed in next Release] WC Product Archive not working (sorting of price)

This support ticket is created 3 years, 11 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Tagged: 

This topic contains 6 replies, has 2 voices.

Last updated by Nigel 3 years, 8 months ago.

Assisted by: Nigel.

Author
Posts
#1876665

I have unchecked "Use default WooCommerce sorting for product archives." in the settings, I have added a sorting by price on the WC archive built with Blocks, and it does not sort by price.

See here for yourself:
hidden link

If sorting by price it does not sort by price.

I believe it is because the sort query forces STRING like so hidden link
But I am not sure, and I am not sure how we could change that anyway, as there is no setting for determining the wpv_sort_orderby_as

In any case, it seems to be not working, I tried also with _price and regular price of WC, this current is the wpv price field of Views WooCommerce.

A hint or fix would be appreciated, the shop should be possible to be sorted by price.

#1877137

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hello Beda!

We have two internal tickets about this already, one relating to problems changing WooCommerce sorting more generally, and another specifically about sorting Views where the custom field should be a number rather than a string (which is not limited to WC, but does I think reflect your issue).

They are under active development at the moment (a fix was proposed, but failed testing), so I would expect some progress soon.

I'm adding your thread to both tickets, and I'll keep you posted.

#1884967

Hi Nigel, Sorry, I didn't receive the email here, hence the late reply.

Kind of show stopping to have a Shop/Products Archive without a working price sorter 🙂
Can I ask if the bug is confirmed in WooCommerce Archive styled with Blocks, and what would be the correct URL attribute?

Perhaps I can fix this/patch it myself temporarily for the client.
It is sort of the only thing that really makes sense to "order by" on a product archive that shows properties to rent/sell.

I tried all possible URL attributes from num, to number, numeric, but it never works well, so I think this is additionally related to the interference run by WC on archives, for which the setting "Use default WooCommerce sorting for product archives." would be, which I have unchecked diligently

Would be real cool to have:
1. Confirmation the bug exists (So I can safely tell the client we will, sooner or later, get the fix)
2. If possible, a patch or even dirty URL edit which I could do for a temporary fix would really be cool as well

Cheers and Merry Christmas + Happy New year to you and the Toolset Team!

#1885297

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Beda

I just tried to see what I could get working on my local test site, and it's flat out not working.

A couple of observations.

1. if you add sorting by price to the product archive, it's likely you are trying to sort by the special custom field created by WooCommerce Blocks, views_woo_price, but that field will only be set if you run the job in Toolset > WooCommerce Blocks that copies across the values from the hidden WC fields. If you haven't done that then you would be adding a sorting control for a field that has no values.

2. Alternatively, you could go to Toolset > Settings > Front-end Content and in the hidden fields settings expose the native WC _price field, which would then be available when you insert the sorting controls.

But in either case, it makes no difference because this is currently not working. What I found was that on the initial page load the results are displayed in some particular order. Whenever you apply the sorting control the results update in some other order, but that new order always seems to be the same regardless of what you choose in the sorting control.

We have an internal ticket for that, and it is on the board for the next dev cycle, the main focus of which will be WooCommerce as well as improved filters (options as well as styling). I already added this to that ticket, and work should begin fairly early in the new year, as most of the work on the current dev cycle is already complete and we should be heading into testing soon, once Christmas vacations are over etc.

The ticket to fix the problem of sorting numbers as strings is marked as fixed in 3.4/1.4, which are for the current dev cycle and should be out early next year.

It may be possible to intervene in the underlying queries with pre_get_posts (recall, there are no Views filters for custom archives), but I'm running out of time myself before breaking up for Christmas to try that.

#1961301

Hi Nigel, I recently updated that site and the issue doe not seem fixed.
I notice version 1.4/3.4 is out, so the fix did not make it?

I also had tried the workarounds you mention and am aware of the difference between WC field/WCV Field, however as you mention it didn't work in either mode for me.

A visible example with all updated plugins can be seen here hidden link

It would be cool to get a fix on that, a Shop with a broken price sorting can be a bit embarrassing 🙂

#1962355

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Beda

The current stable releases still suffer from the problem. This development cycle is focusing on WooCommerce, and the internal ticket for this very issue is currently in progress, but it will be completed in the current cycle. The intention is to have the work completed in time for the WordPress 5.7 release, the tentative release date for which is March 9.

#1980583

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Beda

FYI this was just marked as fixed in develop and will be included in the upcoming release, which is due towards the end of the month (I can't be more specific than that).

I'll update again when it's out.