Skip Navigation

[Resolved] Cannot sort products (WooCommercer) by Price with Views using URL parameter

This support ticket is created 5 years, 9 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/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by Luo Yang 5 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#1224208
Screen Shot 2019-04-01 at 23.39.13.png
Screen Shot 2019-04-01 at 23.39.27.png

I am trying to:
Cannot sort the results (WooCommerce Products ) by Price with Views using URL Parameter correctly.

Link to a page where the issue can be seen:

Page (View using wpv-woo-product-price ) - hidden link

Page (View using field-views_woo_price) - hidden link

I expected to see:
Products sorted correctly from lowest to highest price.

Instead, I got:

However, this is not the case, the products are not sorted correctly in both cases.

Question :
What is the difference between wpv-woo-product-price and field-views_woo_price ? Anyway, none of these two is working when sorting products by price. wpv-woo-product-price gives the same number of results as other sorting criteria (sorting by product's title) whereas field_views_woo_price does not give the same number of results and does not sort the products correctly.

#1224327
sortby-price.JPG

Hello,

I assume we are talking about a normal post view, querying product posts.

Yes, it is possible to sort the results by field "views_woo_price", see it in your website:

ASC order:
hidden link

DESC order:
hidden link

You will need to use order by "as a number" option, see screenshot: sortby-price.JPG

The custom field "views_woo_price" is a feature of Woocommerce Views plugin:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-woo-product-price

#1243992

Thanks for your response but I need to sort it based on the woocommerce price field and not based on views_woo_price field. How is that possible?
The issue with views_woo_price is that I have to maintain the price at 2 places. One is woocommerce price field and another is this views_woo_price field.

#1244361

I assume we are talking about the custom field "_price" of Woocommerce plugin, it is a hidden field, you can try these:
Dashboard-> Toolset-> Settings-> Front-end Content
in section "Hidden custom fields", click button "Select custom fields", find and enable option "_price".

Then you will be able to use field "_price" to sort the Views result.

#1244545

Thanks for your response,
I also need to Sort books by a custom field containing author's last name (and then sort books' titles alphabetically - using nested View) . How is that possible?
This author's last name is coming from another custom post type which is related to woo commerce product using Toolset relations. Let me know if it is clear to you?

New threads created by Luo Yang and linked to this one are listed below:

https://toolset.com/forums/topic/sort-books-by-a-custom-field-containing-authors-last-name/

#1244895

I assume the original question of this thread is resolved, for the new question, please check the new thread here:
https://toolset.com/forums/topic/sort-books-by-a-custom-field-containing-authors-last-name/