We use cookies to improve our services and provide a better experience. By continuing to use this site, you agree with our Cookies Policy.

More than 400 step-by-step articles to guide you through online project development.
HomeTutorialsCMS TutorialsosCommerceosCommerce Administration

How to remove the product attribute drop-down box if only one attribute

Sometimes it might happen that the product will have only one attribute displayed in the store frontend. Therefore, it might look better if the attribute drop-down box would be removed and the attribute itself would be displayed as text.

By default, such behavior is not implemented in osCommerce system. For this reason we might need to edit the code by replacing specific function with new one. One of the ideas how such feature could be implemented is provided below.

Open file “product_info.php” for editing and find the line similar to this one.

<?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?>

Replace it with the following line of code.

<?php echo (sizeof($products_options_array) == 1 ) ? tep_draw_radio_field('id[' . $products_options_name['products_options_id'] . ']', $products_options_array[0]['id'], true) . $products_options_array[0]['text'] :  tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?>

Save the file in order to apply the changes. With only such implementation, product attributes drop-down box should be removed in the case there will be only one attribute.

Rate this Tutorial:
No CommentsLeave a Comment

Other (192)

Popular Keywords