About Club osCommerce

Showcasing osCommerce - the good, the bad and the ugly!

StumbleUpon It! DIGG It!

Just a few products? Dump the categories…

Written By Gary on Apr 03 2008 ·

Years back I had a client who had only a few products in his store. Rather than use the category infoBox I rewrote it to simply give a direct link to each product.

It's funny that I was looking at that store the other day (it's on the Hot 100 list), and today someone in the osCommerce Forum asked for exactly the same thing.

Rather than try to find the file I used on that old site, I just rewrote the script. 2 minutes later, and here we are;

PHP:
  1. <?php
  2. /*
  3.   $Id: categories.php
  4.   osCommerce, Open Source E-Commerce Solutions
  5.   http://www.oscommerce.com
  6.   Copyright (c) 2003 osCommerce
  7.   Released under the GNU General Public License
  8.  
  9.   Copyright (c) www.clubosc.com
  10. */
  11. $products_query = tep_db_query("select distinct p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by pd.products_name ");
  12. ?>
  13. <!-- categories //-->
  14.           <tr>
  15.             <td>
  16. <?php
  17.     $info_box_contents = array();
  18.     $info_box_contents[] = array('text' => BOX_HEADING_CATEGORIES);
  19.  
  20.     new infoBoxHeading($info_box_contents, false, false);
  21.  
  22.     $products_list = '<ul>';
  23.     while ($products = tep_db_fetch_array($products_query)) {
  24.       $products_list .= '<li><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products['products_id']) . '">' . $products['products_name'] . '</a></li>';
  25.     }
  26.     $products_list .= '</ul>';
  27.  
  28.     $info_box_contents = array();
  29.     $info_box_contents[] = array('text' => $products_list);
  30.  
  31.     new infoBox($info_box_contents);
  32. ?>
  33.             </td>
  34.           </tr>
  35. <!-- categories_eof //-->

What this script will do is simply list all your products in a long list, instead of the category box. Easy as 123, eh?

Obviously if you use this script, you will need to set a style on the <ul and maybe the <li - depends upon what you want the list to look like ;)


Buy Gary A Beer?
Buying me a "beer" helps me to keep my contributions updated and keep this blog alive. Cheers!


3 Comments

  1. Hi Gary,I have a potential client that only offers 1 product to sell. This looks like it could work for this situation. Thanks for the tip!

    Ron

    ps - I like this blog…lots of good info here.

    Comment by Ronaldinho53 — June 26, 2008 @ 1:05 pm


  2. Ron - should work just fine - let me know?

    Comment by Gary — June 26, 2008 @ 1:19 pm


  3. Thanks. I am meeting with him next week so I will keep you posted.

    Comment by Ronaldinho53 — June 27, 2008 @ 6:18 pm


Leave a comment

RSS feed for comments on this post · TrackBack URL

Hot 100 osCommerce Shops

View the osCommerce HOT 100These are the best looking, most exceptional osCommerce Stores as voted for by you.

New to osCommerce - get inspiration from these beautiful shops. Reckon your site has what it takes to become a member of the HOT 100? Submit it!