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

Tutorials
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

USA VPS
Linux Cloud Server
Germany Cloud Servers
Ubuntu VPS
OpenVZ VPS
Windows Cloud Server
KVM VPS
cPanel KVM
Linux KVM Hosting
Brazil VPS

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.

1
<?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.

1
<?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.

Windows Cloud Server
Brazil VPS
Ubuntu VPS
Linux KVM Hosting
OpenVZ VPS
cPanel KVM
Germany Cloud Servers
Linux Cloud Server
KVM VPS
USA VPS
Rate this Tutorial:
No Comments Leave a Comment
Leave a Comment

Other (192)

Popular Keywords