Listing Sub Categories on Parent Category page in WP_Ecommerce

Here we are trying to show sub categories in a grid when the category page is being viewed

In wpsc-products_page.php replace this:

<div class="wpsc_categories wpsc_category_grid group">
<?php wpsc_start_category_query(array('category_group'=> get_option('wpsc_default_category'), 'show_thumbnails'=> 1)); ?>

<?php wpsc_print_subcategory("", ""); ?><a href="<?php wpsc_print_category_url();?>" class="wpsc_category_grid_item  <?php wpsc_print_category_classes_section(); ?>" title="<?php wpsc_print_category_name(); ?>">
<?php wpsc_print_category_image(); ?>
</a>
<?php wpsc_end_category_query(); ?>
</div><!--close wpsc_categories-->

 with this:

<div class="wpsc_categories wpsc_category_grid group">
<?php /**  start of new query **/ ?>
<?php
$category_id = wpsc_category_id();
$getsubs = "SELECT term_id FROM wp_term_taxonomy WHERE taxonomy = 'wpsc_product_category' AND parent = '".$category_id."'";
$subcats = mysql_query($getsubs);
$num_subcats = mysql_num_rows($subcats);


 while ($row = mysql_fetch_row($subcats)) {
  foreach ($row as $subcat){
 $catname = wpsc_category_name($subcat);
 $catimage = wpsc_category_image($subcat);
 $catlink = get_term_link((int)$subcat, 'wpsc_product_category');
  if ($category_id >= 0 || $category_id != '') { ?>
<!--  list subcategories only -->
<div class="wpsc_subcategory_grid_item">
<a href="<?php echo $catlink; ?>"  title="<?php echo $catname; ?>">
<img src="<?php echo $catimage;  ?>" width="200" height="150" /> </a>
<a href="<?php echo $catlink; ?>"  title="<?php echo $catname; ?>">
<?php echo $catname;?> </a>
</div><!--  wpsc_subcategory_grid item -->

<?php }  //EOF if ?>

<?php }  //EOF foreach ?>
<?php    } // EOF while
 ?>

<?php /**EOF new query **/ ?>
</div><!--close wpsc_categories-->

 The variable $num_subcats can be used to test for the presence of sub categories in which case you might want to not display the products list that is displayed by default below the category list.

 if($num_subcats == 0) {
// list the products
}