• What is the best way to access the products in the catalogue?

    1. List all products via the Product Page which is implemented during installation…
    Con – When you have over 1000 products this is unusable – waiting over 1 minute for the page to load is not a great user experience
    2. Create a page and implement the shortcodes to display products by categories…
    Con – With over 50 categories, this is a very laborious and time consuming task that I am trying to avoid
    3. Just force customers to search products to find what they need
    Con – the wordpress search does not search products in Wp e-Commerce

    4. ????????

    How can I achieve categorisation of my products through menus to give users easy access to my product catalogue??? I would have liked some sort of “category” to “page” conversion process but it doesn’t exist…

    Has anyone had similar issues that they have resolved?

    Look forward to hearing back from you…

Viewing 8 replies - 1 through 8 (of 8 total)
  • You could set up pages for each category and use the shortcode to display the category per page.

    Then use the new WordPress menu system to set those pages up in your navigation and use dropdowns for subcategories to save some room…

    Just a thought.

    Thread Starter SJW

    (@whitsey)

    See Point 2 –
    2. Create a page and implement the shortcodes to display products by categories…
    Con – With over 50 categories, this is a very laborious and time consuming task that I am trying to avoid

    Right…

    Well, this might be a long shot (as their code has changed quite a bit), and I haven’t used this in a long time….

    But on an older site I did with this plugin, I used the following code to spit out categories as a nav menu (adjusting CSS to show the dropdown subcategories):

    <div id="cat_menu">
    <ul>
    <?php show_cats_brands(); ?>
    </ul>
    </div>

    Just not sure if that code will work anymore, but it’s worth a shot I suppose.

    Thread Starter SJW

    (@whitsey)

    Thanks but this wont work either… I have categorised the products into 3 groups.

    This solution displays all products regardless of grouping…

    What would be perfect would be this exact piece of code with the ability to filter by group id… So I could have a sub-menu for each one of my 3 groups….

    If only I could code I could probably figure this out….

    Thread Starter SJW

    (@whitsey)

    strike that… Just figured out if I pass the group id to this method it filters by the group id…

    Perfect solution… Now I just need to figure out how to place it in the menu and merge it with the current menu call – wp_list_pages()

    I currently have

    Home
    Group 1
    Group 2
    Group 3
    About Us
    Contact Us

    Is there a way to print:

    Home
    <?php show_cats_brands(1); ?>
    <?php show_cats_brands(2); ?>
    <?php show_cats_brands(3); ?>
    About Us
    Contact Us
    ???

    THanks

    You could just code it that way, like:

    <ul>
    <li><a href="#">Home</a></li>
    <?php show_cats_brands(1); ?>
    <?php show_cats_brands(2); ?>
    <?php show_cats_brands(3); ?>
    <li><a href="#">About Us</a></li>
    <li><a href="#">Contact Us</a></li>
    </ul>

    Not sure of a way to do it dynamically though…with that setup.

    Thread Starter SJW

    (@whitsey)

    Well… None of the solutions that were suggested were what I was looking for so I took pieces from each and ended up creating my own version. show_cats_brands() did about 70% of the job but it lacked formatting for my needs.

    Thought I’d post for anyone wanting to achieve the same goal. I simply took show_cats_brands() function and re-formatted it into a menu. I then added the top level group as the top-level menu and linked it to a page.
    I also created a new option in db (wp_option) called display_empty_cats which is a flag to hide/show categories with 0 products. This function needs additional work because it will hide sub-categories making the category menu empty… Need to enhance the check on the category level to count products in sub-categories…

    function display_wpsc_menu_subcategories($id) {
      global $wpdb;
      $output = "";
    
      if(get_option('permalink_structure') != '') {
        $seperator ="?";
      } else {
        $seperator ="&";
      }   
    
      $subcategory_sql = "SELECT * FROM <code>&quot;.WPSC_TABLE_PRODUCT_CATEGORIES.&quot;</code> WHERE <code>active</code>='1' AND <code>category_parent</code> = '".absint($id)."'  ORDER BY <code>nice-name</code>";
      $subcategories = $wpdb->get_results($subcategory_sql,ARRAY_A);
    
      if($subcategories != null) {
    
        $output .= "<ul class='children'>";
    
        foreach($subcategories as $subcategory) {
    
          // Use db flag to show/hide product count within category
          if (get_option('show_category_count') == 1) {
    
            //show product count for each category
            $count = $wpdb->get_var("SELECT COUNT(<code>p</code>.<code>id</code>) FROM <code>&quot;.WPSC_TABLE_ITEM_CATEGORY_ASSOC.&quot;</code> AS <code>a</code> JOIN <code>&quot;.WPSC_TABLE_PRODUCT_LIST.&quot;</code> AS <code>p</code> ON <code>a</code>.<code>product_id</code> = <code>p</code>.<code>id</code> WHERE <code>a</code>.<code>category_id</code> IN ('{$subcategory['id']}') AND <code>p</code>.<code>active</code> IN ('1') AND <code>p</code>.<code>publish</code> IN('1')");
            $addCount =  " (".$count.")";
    
            // Check if we should display empty categories in menu
            if (get_option('display_empty_cats') == 1) {
              $addCount =  " (".$count.")";
            } else {
              // If not, only continue if there are sub-categories for this category
              if ($count==0) {
                break;
              } else {
                $addCount =  " (".$count.")";
              }
            } // end if getoption(display_empty_cats)
    
          } // end if get_option(show_category_count)
    
          $output .= "<li class='page_item page-item-".$subcategory['id']."'><a href='".wpsc_category_url($subcategory['id'])."'>".stripslashes($subcategory['name']).$addCount."</a></li>";
    
        } // end foreach loop
        $output .= "</ul>";
    
      }
      return $output;
    }
    
    // Build Menu - Pass Group_id for category_tree structure & Page_Id to link the Category Group to a Page
    function show_wpsc_group_menu($category_group = null , $page_id = null, $order_by = 'name') {
      global $wpdb;
      $output = "";
    
      if($category_group == null || $page_id == null) {
        return;
      } else {
        $category_group = (int)$category_group;
        $page_id = (int)$page_id;
        $page_name =  $wpdb->get_var("SELECT <code>meta_value</code> FROM <code>$wpdb->postmeta</code> WHERE <code>post_id</code> IN ('$page_id') AND <code>meta_key</code> = '_aioseop_menulabel' LIMIT 1 ");
        $page_title = $wpdb->get_var("SELECT <code>meta_value</code> FROM <code>$wpdb->postmeta</code> WHERE <code>post_id</code> IN ('$page_id') AND <code>meta_key</code> = '_aioseop_titleatr' LIMIT 1 ");
      }
    
      if(get_option('permalink_structure') != '') {
        $seperator ="?";
      } else {
        $seperator ="&";
      }
    
      // Setup Top Level Group Link
      $output .= "<li class='page_item page-item-".$page_id."'><a href='".get_page_link($page_id)."' title=".$page_title.">".$page_name."</a>";
    
      // Now extract 1st level categories
      $categories = $wpdb->get_results("SELECT * FROM <code>&quot;.WPSC_TABLE_PRODUCT_CATEGORIES.&quot;</code> WHERE <code>group_id</code> IN ('$category_group') AND <code>active</code>='1' AND <code>category_parent</code> = '0' ORDER BY <code>&quot;.$wpdb->escape($order_by).&quot;</code> ASC",ARRAY_A);
    
      // If we have some category levels, let's process them
      if($categories != null) {
    
        $output .= "<ul class='children'>";
    
        foreach($categories as $option) {
    
          // check option for category count
          if (get_option('show_category_count') == 1) {
    
            // show sub-category count for each group
            // (We need to change this to calculate the product count in sub-categories to determine whether or not to display the 2nd level category in menu)
            $count = $wpdb->get_var("SELECT COUNT( * ) FROM <code>&quot;.WPSC_TABLE_PRODUCT_CATEGORIES.&quot;</code> WHERE <code>category_parent</code> IN ('".$option['id']."')");
    
            // Check if we should display empty categories in menu
            if (get_option('display_empty_cats') == 1) {
              $addCount =  " (".$count.")";
            } else {
              // If not, only continue if there are sub-cateogries for this category
              if ($count==0) {
                break;
              } else {
                $addCount =  " (".$count.")";
              }
            } // end if (getoption(display_empty_cats))
    
          } // end if get_option(show_category_count)
    
          $output .= "<li class='page_item page-item-".$option['id']."'><a href='".wpsc_category_url($option['id'])."' title=".stripslashes($option['name']).">".stripslashes($option['name']).$addCount."</a>";
    
          $subcategory_sql = "SELECT * FROM <code>&quot;.WPSC_TABLE_PRODUCT_CATEGORIES.&quot;</code> WHERE <code>group_id</code> IN ('$category_group') AND <code>active</code>='1' AND <code>category_parent</code> = '".$option['id']."' ORDER BY <code>id</code>";
          $subcategories = $wpdb->get_results($subcategory_sql, ARRAY_A);
    
          if($subcategories != null) {
    
            $output .= display_wpsc_menu_subcategories($option['id']);
          }
    
          $output .= "</li>";
        } // end foreach loop
        $output .= "</ul></li>";
      }
      echo $output;
    }

    Hi there I’m very interested in using this code whitsey as I face a similar problem to you, but where are you implementing/inserting this code?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: WP e-Commerce]Accessing Products in Catalogue’ is closed to new replies.