Category wise products display in WP E-Commerce products page

WP E-Commerce displays all the products from all the categories in the default products page which uses the template file: wpsc-products_page.php for displaying. There are situations when we have product categories, under each category we have different products. Now we have to display all the products grouped by product-categories. Like:


We can achieve this using short-codes provided by wp e-commerce, but then we have to write the shortcode that many number of times as we have number of categories.

Find a complete list of wp e-commerce category shortcodes with additional arguments
There are some other problems like: we have to create another product page,write the short codes there and keep the default products page intact, else chances are there that the single product page, category page etc. may break or show page not found error.

So another option is to change the default products-page template file( wpsc-products_page.php ) to display products group by categories. This can be done by running multiple loops in the the products page template file. I have used this once and works fine for me. Use this if it suits your requirement. ๐Ÿ™‚


— Open the wpsc-products_page.php file.
— Find the products loop statement in the code.

— Find the products loop end statement.

— Copy the whole block in between while and endwhile for the product loop.
— Then enclose those copied code inside the below mentioned condition.
— Save and check the products page.

Example Code:


Download the modified wpsc-products_page.php !!


40 responses to “Category wise products display in WP E-Commerce products page”

  1. Hi!
    I want to sort my products by the product category in my website. I use wp-ecommerce and goldcart plugin.
    I have figured out to open the php file, but I saw that between the mentioned rows there is already some code.
    Should I delete it? Or what code should I keep?
    I’m new in using php code and I need more details. Eventualy I can provide to you my php files, wpsc-products_page.php with the default view, and the gridview.php if you can help me.
    Thank you very much for your work,
    Best regards,
    Mihai Antonache

  2. Thank you for your reply Subharanjan!
    I thought that I shall let that code undeleted. But the code provided by you shall be copyed and pasted in my php file and that’s it?
    Or shall I intercalate it with the original code?

  3. Hei Subharanjan,

    I was looking for this so many time and before trying it looks like I need. I don’t understand why e-commerce doesn’t give more facilities for do this (a nice guideline). I tried to do it with old WP-Query but then you have troubles using the wpsc_product function in the loop! Thanks for sharing!

    Greets from Berlin!

  4. Hello Subharajan,

    I use the wp e-commerce and gold cart plugins on my page.
    I tried your solution, but it does’n work.
    If I understand correctly, I download your modified wpsc_products.php file. Delete the original wpsc_products.php file, than I add your wpsc_products.php file.
    I did it, but it isn’t working for me.
    Any idea?
    Please help me!!!

  5. Hi and thanks for your example!

    Is there an easy way to control the order in which the categories are rendered on the page? They seem to render in alphabetical order by default…

  6. Hi and thanks for the tip! I quickly tried modifying the product query arguments array in your example but only managed to change the order of products within a category, NOT the order of categories. Any further tips? ๐Ÿ™‚

    • Yes, my bad… You can modify the code where we get all the Product Categories…

      Before Modification:

      After Modification:

      Various arguments for the “orderby” parameter are: id, count, name – Default , slug, term_group, none

      Hope this helps….

  7. Thanks a lot for this post, you saved my life !!

    My customer asked me to offer two different displays for a category page: all products on one single page, or on several pages using pagination.
    I changed a bit your code to fit my needs and it seems to be working quite well !
    You can find it here: (still work in progress but thanks to you I will be able to work on the rest of the website ๐Ÿ™‚

    Thanks again

  8. Hi again!

    I was wondering if it is possible to somehow fix the order of the product categories? E.g. if I have categories “Books”, “Cars”, “Doors” and “Elephants” how can I sort them in this order:
    – Doors
    – Books
    – Elephants
    – Cars

    or any other order I’d like?

    From the database I can see that the categories have “term_id” but I don’t want manipulate those values to create the order I want. That would probably just break something…

  9. Hi

    I try to do that, i copied already, but it wasnt work for me. After i tryed the file, which i download, but it was the same.

    Is it works by the newest ecommerce as well?

    • I haven’t tried this on the latest e-commerce though, but it should work. Will check and get back…
      Before that, can you check if you have the same file inside your current theme directory as well as inside the e-commerce plugin theme folder ?

  10. Hi and thanks for your example!

    I have used wp-ecommerce plugin in my site and is working fine. I have used your code to display categorywise products on the product page. Also I have set the product page as my website’s homepage. Now when I click on the category name from homepage I get page not found error.

    Any idea??

    Please help!

  11. I am looking to customize the display a little. I would like to have a grid view of the categories only when clicking on the “Products Page” then when a category is clicked I want it to display only items from that category, with out the grid view of categories. Can this be done?

  12. Hi Subharanjan, thanks for the fantastic code. I’m trying to split my products by category on to two separate tabs within my products page. I have the basic idea working but just can’t work out how to specify the category – at present the same category is repeated on both. Any idea what I’m doing wrong?

    Many thanks!

  13. Hey! I was able to resolve the issue. Thanks!

    I had another query.I want to integrate Amazon checkout for payments in wp-ecommerce.

    Anyone having idea about this?

    Thanks in advance.

  14. Hi Subharanjan, thanks for the code. Can you help me because i want each category title to have link so that it will go to the category page. Thanks.

  15. Hi, Subharanjan

    This is Omkar

    I have downloaded the modified wpsc-products_page.php that you have given above and replaced it with the existing file, but nothing happened. I am not a developer. can you help for the same?. I have to show on product page

    1st level sub category
    2nd level sub category

    n th level sub category
    Product details

    here goes a link of my site

    something like this

    if you click on optics it opens to sub categories in optics and so on….

  16. How i can modify code on next structure:

    โ€“ Subcategory
    โ€“ Product #1
    โ€“ Product #2
    โ€“ Product #3
    โ€“ Subcategory
    โ€“ Product #4
    โ€“ Product #5
    โ€“ Subcategory
    โ€“ Product #6
    โ€“ Product #7
    โ€“ Product #8
    When we go in Product-Category – we can look thumbs category, after click on Product category – we look Subcategory thumbs, and then after click on Subcategory we will see Products

    How can modify code?


  17. Hi,

    How could i display product on date wise?


    If i want to display some product on monday then how could i can dispplay that?


Leave a Reply