Qwackmaster Posted November 30, 2002 Share Posted November 30, 2002 Hey Guys! I want to display 3 items in my Specials Box. I have tried a number of different modifications to the catalog>includes>boxes>specials.php but I haven't been able to make it work. Hoping someone here can help me with the proper PHP coding. Ultimately, I want it to look like this: You've tried to philosophize your pain but the hurt's in your heart and not in your brain Link to comment Share on other sites More sharing options...
Guest Posted November 30, 2002 Share Posted November 30, 2002 In the admin side of the store admin/configuration/maximum values and set special product to 3 Regards Link to comment Share on other sites More sharing options...
Qwackmaster Posted November 30, 2002 Author Share Posted November 30, 2002 Nope. I'm not talking about how many items are displayed on the specials page. I need 3 items in the SPECIALS BOX...the one that appears on default.php :D You've tried to philosophize your pain but the hurt's in your heart and not in your brain Link to comment Share on other sites More sharing options...
kagg Posted November 30, 2002 Share Posted November 30, 2002 You may try as follows: (just a try) Modify Line 15 in specials.php as follows: if ($random_product_query = tep_random_select("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 p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '" . $languages_id . "' and s.status = '1' order by s.specials_date_added DESC limit 3" . MAX_RANDOM_SELECT_SPECIALS)) { here 3 has been added in line. Also insert the following line at line27: while ($random_product= tep_db_fetch_array($random_product_query )){ then close the curly braces before: new infoBox($info_box_contents); Please make a copy of original specials.php for security. :wink: kagg Link to comment Share on other sites More sharing options...
Qwackmaster Posted November 30, 2002 Author Share Posted November 30, 2002 Hey Kagg! Thanks for the help. I am having trouble with the proper way to insert your code into line 27. I've tried several things but I keep getting parse errors. Wondering if you can help me with the exact syntax. Here's lines 27-31. Thanks a MILLION! $info_box_contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product["products_id"], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id'], 'NONSSL') . '">' . $random_product['products_name'] . '</a><br><s>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>' ); new infoBox($info_box_contents); You've tried to philosophize your pain but the hurt's in your heart and not in your brain Link to comment Share on other sites More sharing options...
mattice Posted November 30, 2002 Share Posted November 30, 2002 Could be wrong but I think the function tep_random_select() returns a single row by default? "Politics is the art of preventing people from taking part in affairs which properly concern them" Link to comment Share on other sites More sharing options...
kagg Posted November 30, 2002 Share Posted November 30, 2002 Here is the code: while ($random_product= tep_db_fetch_array($random_product_query )){ $info_box_contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product["products_id"], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id'], 'NONSSL') . '">' . $random_product['products_name'] . '</a><br><s>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>' ); } new infoBox($info_box_contents); Could be wrong but I think the function tep_random_select() returns a single row by default? May be you are right mattice. But I think we can try, if this does not work then we will select the product by order. Kagg Link to comment Share on other sites More sharing options...
Qwackmaster Posted November 30, 2002 Author Share Posted November 30, 2002 Well, I think we're close, but the code offered above yields this: I tried it several times and double/triple checked. Seems we need some more tweaking. You've tried to philosophize your pain but the hurt's in your heart and not in your brain Link to comment Share on other sites More sharing options...
kagg Posted November 30, 2002 Share Posted November 30, 2002 Replace line15 with following: if ($random_product_query = tep_random_select("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 p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '" . $languages_id . "' and s.status = '1' order by s.specials_date_added DESC limiit 3)) { kagg Link to comment Share on other sites More sharing options...
Ajeh Posted November 30, 2002 Share Posted November 30, 2002 The function tep_random_select pulls one row and returns the already processed tep_db_fetch_array So ... what I did, and this is not perfect as it can product duplicated, although I am sure there is a smart way to do this without the duplicated is this: $info_box_contents = array(); $row=0; while ($row <= 2) { $row++; $random_product = tep_random_select("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 p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '" . $languages_id . "' and s.status = '1' order by s.specials_date_added DESC limit " . MAX_RANDOM_SELECT_SPECIALS); $info_box_contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product["products_id"], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id'], 'NONSSL') . '">' . $random_product['products_name'] . '</a><br><s>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>' ); } new infoBox($info_box_contents); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.