While WP e-Commerce lets you choose how to order your products (E.g. Price, Name, Date Uploaded) through the admin area, it doesn’t let you control whether you’re sorting ascending or descending – e.g. cheapest first, or most expensive first.
Here’s a a quick tip to show how to control the sort order, just add the following snippet to your WordPress theme’s functions.php file:
<?php if (!isset($_SESSION['wpsc_product_order'])) { $_SESSION['wpsc_product_order'] = "DESC"; } ?>
Just swap DESC for ASC to swap the default order. Happy sorting …
July 8, 2010 at 12:34 am
This caused the site to start throwing errors for me – something about cannot resend headers.
July 8, 2010 at 7:12 am
Sounds like you’ve made functions.php output some characters when it shouldn’t. This will either be because there are syntax errors in the file, or there are extra spaces / newlines outside of the tags.
October 28, 2010 at 12:17 am
Hurray! I finally got to work! This is preferred as every time I upgrade WP ecommerce, I’ve been having to re-edit the wpsc_query.php file, Now I won’t have to.
Yippee!!!
March 17, 2011 at 6:07 pm
Thank you , such a simply line of code to add , suprised I coulnd’t find it on http://getshopped.org/forums/!
May 9, 2011 at 7:11 pm
I got this in the funtions file…but it is not changing the sort order…i am using the new version of the cart now 3.8 is there a fix for that version?
Thanks
May 9, 2011 at 7:57 pm
Try this (untested):
function my_reverse_sort_order($order) {
return "DESC";
}
add_filter('wpsc_product_order', 'my_reverse_sort_order');
May 28, 2011 at 6:07 pm
Thank u Lee! It Works!
June 14, 2011 at 2:51 am
Thanks, it works perfectly! 😀
July 26, 2011 at 6:21 am
Thanx man, i was few days searching for this.. thnx
January 4, 2012 at 10:33 pm
Lovely work… cheers Lee!
February 29, 2012 at 12:30 am
I could find any answer at their forum but finally I got your code and worked!!
Thank you!!!
March 10, 2012 at 10:03 am
I just used function my reverse_sort_order. It yielded Fatal error: Cannot redeclare my_reverse_sort_order().
Getshopped.org posted new update, http://docs.getshopped.org/documentation/chaging-the-product-order-from-ascending-to-descending/
May 21, 2012 at 8:06 pm
Thanks! Worked like a charm.
July 20, 2012 at 10:56 pm
It is really works!
Thank you a lot!
Strange that this functionality was not added in e-commerce admin…
July 26, 2012 at 3:34 pm
Thank you so much lee!! it works!!!
October 16, 2012 at 5:38 pm
Thank you for this! My client has been asking me to figure out how to reverse the order of her products, and nothing I’ve done has helped, until I found this. It worked beautifully.
August 2, 2011 at 11:12 pm
Thanks this worked perfectly! Amazing that WP E-commerce didn’t build this in as an option through the admin panel
August 5, 2011 at 6:22 pm
where do i find the file to paste that into?
August 5, 2011 at 7:59 pm
It goes in your theme’s function.php which will be in wp-content/themes//
August 14, 2011 at 2:32 pm
hi! i’m currently using WPE-C v3.8.5 and your both solutions isn’t working. something has changed in this plugin since may, when you posted your last solution?
also checked for drag’n’drop sorting and it also does not work.
August 14, 2011 at 11:48 pm
nevermind, I used this plugin: http://www.gab.ro/post-sorting-reloaded/
with:
Condition 1 – get_post_type()
Sort type 1 – post_date DESC
August 20, 2011 at 1:29 pm
could you use something similar to this to re-order categories by number?
currently I have 9 categories that are displayed in alphabetical order like so :
1 2 3
4 5 6
7 8 9
but I need to order them like this:
7 8 4
5 2 9
1 3 6
Is there a way of specifying exactly which order categories get displayed?
I had thought of editing the template to include each category in my order but not sure if I can specify one template for the main products page and a different template for single product pages.
August 20, 2011 at 5:33 pm
I’m not aware of any way to do that currently.
September 1, 2011 at 1:29 am
But do you know how we can sort categories by id asc or desc?
September 1, 2011 at 3:08 pm
It’s not something I’ve looked at sorry. I’d try the forums at http://getshopped.org/forums/
October 11, 2011 at 5:20 pm
I agree with corell, unfortunately it looks like this solution has been rendered redundant with the updates of wpec or wp. 🙁 🙁 🙁 Thanks though.
October 28, 2011 at 6:39 am
I need this to work badly. So weird that the first products added to the store come FIRST! Help!
October 28, 2011 at 6:43 am
This still works for me – I read the other’s comments and panicked.
Add this to the very end of your functions.php file (and don’t forget to note this in your development docs so you don’t forget when you update!) :
November 2, 2011 at 2:06 am
Thanks so much for this solution!
November 29, 2011 at 10:56 pm
Does anyone know if this code can be adapted to sort the customer’s view i.e. the product page. I know there’s a plugin to sort by price ranges, but I’d like to give the customer the choice of sort by price hi-to-low and low-to-hi?
Anyone’s help would be MUCH appreciated!
January 19, 2012 at 7:33 pm
I’m also interested in how to do this on the customer side.
I as admin would like to choose wich products comes up first when the users views “all” products.
Bonus would be to give users the ability to sort aswell.
February 27, 2012 at 6:58 pm
I am also interested to give sorting option to user (by name, price, sku) on all products page and category page.
please figure it out.
April 23, 2012 at 9:56 pm
me too, interested to give sorting option to user (by name, price) on all products page and category page.
Thanks a lot,
April 29, 2012 at 4:13 pm
In wp-e-commerce, in order to sort objects per prise DESCending:
/www/wp-content/plugins/wp-e-commerce/wpsc-core/wpsc-functions.php
Replace:
‘order’ => apply_filters(‘wpsc_product_order’,’ASC’)
by
‘order’ => apply_filters(‘wpsc_product_order’,’DESC’)
June 16, 2012 at 4:39 am
i am not able to get it at all, i coundnt find ‘order’= apply-filters(‘wpsc_pruduct_order’;ASC’)
October 23, 2012 at 2:57 pm
When I Replace:
‘order’ => apply_filters(‘wpsc_product_order’,’ASC’)
by
‘order’ => apply_filters(‘wpsc_product_order’,’DESC’)
http://naiscosmetics.lv/veikals/ work ok, but when I change page to other for example
http://naiscosmetics.lv/veikals/2/ I got blank page
where could be problem!
June 9, 2012 at 8:56 am
what an easy fix! Thanks
July 7, 2012 at 11:19 am
product sorting usin sku value how it possible
August 29, 2012 at 5:49 pm
You are THE MAN Lee…..
August 29, 2012 at 8:17 pm
Thank you! this has solved me some serious headaches! amazing.
October 18, 2012 at 9:05 am
great help!
can you also tell what should we do to sort our product to Newest first in product page
June 13, 2013 at 9:20 am
Work perfect ! thank you very much….