Lee Willis

Reverse the product order in WP e-Commerce

| 42 Comments

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 …

42 Comments

  1. This caused the site to start throwing errors for me – something about cannot resend headers.

    • 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.

      • 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!!!

  2. Thank you , such a simply line of code to add , suprised I coulnd’t find it on http://getshopped.org/forums/!

  3. 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

  4. Thanks this worked perfectly! Amazing that WP E-commerce didn’t build this in as an option through the admin panel

  5. where do i find the file to paste that into?

  6. 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.

  7. 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.

  8. I agree with corell, unfortunately it looks like this solution has been rendered redundant with the updates of wpec or wp. 🙁 🙁 🙁 Thanks though.

  9. I need this to work badly. So weird that the first products added to the store come FIRST! Help!

  10. 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!) :

  11. Thanks so much for this solution!

  12. 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!

  13. 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.

  14. 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.

  15. me too, interested to give sorting option to user (by name, price) on all products page and category page.

    Thanks a lot,

  16. 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’)

  17. what an easy fix! Thanks

  18. product sorting usin sku value how it possible

  19. You are THE MAN Lee…..

  20. Thank you! this has solved me some serious headaches! amazing.

  21. great help!
    can you also tell what should we do to sort our product to Newest first in product page

  22. Work perfect ! thank you very much….

Leave a Reply

Required fields are marked *.