minghoo Posted August 16, 2010 Share Posted August 16, 2010 this is specials.php under catalog/include/modules/ to show special products on homepage( catalog/index.php) it works perfectly, but the only problem is it shows title bar with special text if there is no special products. <?php /* $Id: default_specials.php,v 2.0 2003/06/13 osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ ?> <!-- default_specials //--> <tr> </tr> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <?php if (!defined('PRODUCT_LIST_COLUMNS_SPECIALS')) { tep_db_query( "insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Number of products per row on specials products modules', 'PRODUCT_LIST_COLUMNS_SPECIALS', '5', 'Set the number of products per row to display?', '8', '26', now());" ); define('PRODUCT_LIST_COLUMNS_SPECIALS', '5'); } if (!defined('MAX_DISPLAY_SPECIALS_PRODUCTS_MODULE')) { tep_db_query( "insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Maximum number display special products on speical modules', 'MAX_DISPLAY_SPECIALS_PRODUCTS_MODULE', '10', 'Set maximum number of products to display?', '8', '27', now());" ); define('MAX_DISPLAY_SPECIALS_PRODUCTS_MODULE', '10'); } $info_box_contents = array(); $info_box_contents[] = array('align' => 'left', 'text' => sprintf(TABLE_HEADING_SPECIALS_PRODUCTS_MODULE, strftime('%B'))); new infoBoxHeading($info_box_contents, false, false, tep_href_link(FILENAME_SPECIALS)); // descending by date version $new = tep_db_query("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and s.status = '1' order by s.specials_date_added DESC limit " . MAX_DISPLAY_SPECIALS_PRODUCTS_MODULE); $info_box_contents = array(); $row = 0; $col = 0; while ($default_specials = tep_db_fetch_array($new)) { $default_specials['products_name'] = tep_get_products_name($default_specials['products_id']); $info_box_contents[$row][$col] = array('align' => 'center', 'params' => 'class="smallText" width="'. round(100/PRODUCT_LIST_COLUMNS_NEW_PRODUCTS) .'%" valign="top"', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $default_specials["products_id"]) . '">' . tep_image(DIR_WS_IMAGES . $default_specials['products_image'], $default_specials['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $default_specials['products_id']) . '">' . $default_specials['products_name'] . '</a><br><s>' . $currencies->display_price($default_specials['products_price'], tep_get_tax_rate($default_specials['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price($default_specials['specials_new_products_price'], tep_get_tax_rate($default_specials['products_tax_class_id'])) . '</span>'); $col ++; if ($col > (PRODUCT_LIST_COLUMNS_SPECIALS-1)) { $col = 0; $row ++; } } while ($col != 0 && sizeof($info_box_contents[$row]) < PRODUCT_LIST_COLUMNS_SPECIALS) { $info_box_contents[$row][$col] = array( 'align' => 'center', 'params' => 'width="'. round(100/PRODUCT_LIST_COLUMNS_SPECIALS) .'%"', 'text' => ' ' ); $col ++; } new contentBox($info_box_contents); ?> <!-- default_specials_eof //--> anyone got ideas how to change the code? thanks Sean My contributions: EZ new fields easy way add Qty box in your product_info.php Link to comment Share on other sites More sharing options...
Guest Posted August 16, 2010 Share Posted August 16, 2010 Sean, This has already been done: http://addons.oscommerce.com/info/6653 Chris Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.