Tuesday, August 7, 2012

know subcategory is in category or not in wp-ecommerce wordpress plugin

$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); //this gets the ids of the subcategories
$num_subcats = mysql_num_rows($subcats); //this is a count of how many subcategories the current category has
<?php $parentcatname = wpsc_category_name();
$category_id= wpsc_get_parent_category_id($parentcatname); ?>
<?php wpsc_start_category_query(array('parent_category_id' => $category_id, 'show_thumbnails'=> get_option('show_category_thumbnails')));

<!-- product category name display -->
                        <div style="float:left; margin-right:50px; margin-bottom:10px;">
                        <div class="sub_cat_title">
<a href="<?php wpsc_print_category_url();?>" class="wpsc_category_link <?php wpsc_print_category_classes_section(); ?>" title="<?php wpsc_print_category_name(); ?>"><?php wpsc_print_category_name(); ?></a>
  <a href="<?php wpsc_print_category_url();?>">
wpsc_print_category_image(get_option('category_image_width'), get_option('category_image_height')); ?>
<?php if(wpsc_show_category_description()) :?>
<?php wpsc_print_category_description("<div class='wpsc_subcategory'>", "</div>"); ?>
<?php endif;?>
<?php  wpsc_print_subcategory("<ul>", "</ul>"); ?>

<?php wpsc_end_category_query(); ?>

  <?php  if ($num_subcats == 0) { ?>
//product show code here
<? } ?>

No comments:

Post a Comment