Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to display all products in a drop down menu?


kcargin

Recommended Posts

Does anyone know how to add an infobox that would be a drop down/ pull down menu of all products available? I've found the contribution for category pull down, but haven't found one for products.

 

Thanks

Link to comment
Share on other sites

I've found the contribution for category pull down, but haven't found one for products.

cause probably the pull down would be way too long.

But if you have a small number of products you can create a products.php file in catalog/includes/boxes/ and place inside:

<?php

/*

 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com



 Copyright (c) 2001 osCommerce



 Released under the GNU General Public License

*/



 function tep_get_products() {

   global $languages_id;



   $products_array[] = array('id' => '', 'text' => PULL_DOWN_DEFAULT);



   $products_query = tep_db_query("select p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by pd.products_name");

   while ($products = tep_db_fetch_array($products_query)) {

     $products_array[] = array('id' => $products['products_id'],

                                 'text' => $products['products_name']);

   }



   return $products_array;

 }



?>

<!-- products //-->

         <tr>

           <td>

<?php

   $info_box_contents = array();

   $info_box_contents[] = array('text' => BOX_HEADING_PRODUCT);

   new infoBoxHeading($info_box_contents, false, false);

 

   $info_box_contents = array();

 

   $info_box_contents[] = array('form' => '<form action="' . tep_href_link(FILENAME_PRODUCT_INFO) . '" method="get">' . tep_hide_session_id(),

                               'align' => 'left',

                               'text'  => tep_draw_pull_down_menu('products_id', tep_get_products(array('id' => '', 'text' => PULL_DOWN_DEFAULT)), $products_id, 'onchange="this.form.submit();"')

                               );

   new infoBox($info_box_contents);

?>

        </td>

      </tr>

           

<!-- products_eof //-->

Remember to define BOX_HEADING_PRODUCT in your language file and to place the new products.php box in right or left column.

HTH

Ivan

Link to comment
Share on other sites

Hey - I tried doing this and everything is correct on my catalog page and I have the pull down named 'QuickShop', but when I go to an actual product page the heading on my pull down reverts to BOX_HEADING_PRODUCT. What am I doing wrong?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...