WP eCommerce
Get Product LAST category ID on single_product.php (1 post)

  1. AnselTk1
    Posted 1 year ago #

    Wondering if some kind soul out there can help. I've tried numerous things, but can't seem to figure it out.

    I need a way to reliably get the

    sub/child category ID of a product as a variable. This is on my single_product PHP template page.

    I have used this on my category grid page, which works, but it does not work on the single product page:

    <?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);

    and then run the results through and get the values...

    Although the above doesn't help in determining what the last child category is (other than ordering the results) and also as far as I can tell wpsc_category_id() does not seem to work on the single product template.

    Can anyone help? I'm really struggling with this.


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.