Skip Navigation

[Resolved] WooCommerce archive order on price not working

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

Problem:
The user configured the products archive template to be ordered by the price but that did not work for him.

Solution:
It turns out that the price was ordered as a string instead of a number, I updated the wpv-sort-orderby to include the following argument orderby_as_numeric_for="field-views_woo_price" and it is giving correct results.

[wpv-sort-orderby type="select" options="post_date,post_title,field-views_woo_price" label_for_post_date="Newest" label_for_post_title="A to Z" label_for_field-views_woo_price="Price" orderby_as_numeric_for="field-views_woo_price" orderby_ascending_for="post_date,post_title,field-views_woo_price"]

Note, that a product does not have a price, it is considered to have a price equals to 0.

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
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: Africa/Casablanca (GMT+01:00)

This topic contains 3 replies, has 2 voices.

Last updated by umbertoZ 4 years, 2 months ago.

Assisted by: Jamal.

Author
Posts
#1780337

Hey, thank you! The Frontend Sorting setting was the problem.

Now sorting is working well by title (A-Z/Z-A) and by date (Newest/Oldest), but it is still giving a weird result by woo_price. It is not ordering correctly.

This is the shortcode of my View:

[wpv-sort-orderby type="select" options="post_date,post_title,field-views_woo_price" label_for_post_date="Newest" label_for_post_title="A to Z" label_for_field-views_woo_price="Price" orderby_ascending_for="post_date,post_title,field-views_woo_price"]

[wpv-sort-order type="radio" options="asc,desc" label_for_asc="Ascending" label_for_desc="Descending" label_asc_for_post_date="Older first" label_desc_for_post_date="Newer first" label_asc_for_post_title="A to Z" label_desc_for_post_title="Z to A" label_asc_for_field-views_woo_price="Low to high" label_desc_for_field-views_woo_price="High to low"]
#1780341

To better assist with this issue, I'll need to take a closer look at your view. Please allow me temporary access to your website. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#1781279

It turns out that the price was ordered as a string instead of a number, I updated the wpv-sort-orderby to include the following argument orderby_as_numeric_for="field-views_woo_price" and it is giving correct results.

[wpv-sort-orderby type="select" options="post_date,post_title,field-views_woo_price" label_for_post_date="Newest" label_for_post_title="A to Z" label_for_field-views_woo_price="Price" orderby_as_numeric_for="field-views_woo_price" orderby_ascending_for="post_date,post_title,field-views_woo_price"]

Please note, that a product does not have a price, it is considered to have a price equals to 0.

I hope this helps. Let me know if you have any questions.

#1787275

My issue is resolved now. Thank you!