albundy Posted December 4, 2007 Share Posted December 4, 2007 hi, i have found the just bought contribution for oscommerce. I have alter the script so that it can also show place and country where the last has been bought. However the contribution is a box item which only refresh on page refresh. I want it more dynamic so that it shows every XX second a new record without refreshing the whole page. Is this possible and if so is there anybody who can help to make this work? below is the script Marcel <?php /* $Id: justbought.php,v 1.0 2004/06/24 22:31:00 by Johannes Teitge, http://www.shopexpress.info osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ ?> <!-- justbought //--> <?php global $languages_id; // seconds the last bought products are shown (Set in admin) $timelimit = JUSTBOUGHT_SECONDS; //$products_query = tep_db_query("select op.products_id from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op where UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(o.date_purchased) < ".$timelimit." and o.orders_id = op.orders_id"); $products_query = tep_db_query("select op.products_id from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op where (UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(o.date_purchased) < ".$timelimit.") and o.orders_id = op.orders_id"); $bought_products = array(); while ($products = tep_db_fetch_array($products_query)) { $bought_products[] = $products['products_id']; } $products_count = count($bought_products); if ($products_count > 0) { $selitem = $random = mt_rand(0, $products_count-1); $product_query = tep_db_query("select p.products_id,p.products_image, pd.products_name, o.customers_city, o.customers_country from " . TABLE_PRODUCTS . " p, " . TABLE_ORDERS . " o, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id=".$bought_products[$selitem]." and p.products_id=pd.products_id and pd.language_id=".$languages_id); if ($product = tep_db_fetch_array($product_query)) { echo("\n<tr><td><br>\n"); $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_JUSTBOUGHT); // To hide the hide use admin if (JUSTBOUGHT_SHOWHEADER == 'true') { new info2BoxHeading($info_box_contents, false, false, tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product["products_id"])); } $info_box_contents = array(); $info_box_contents[] = array('text' => '<table cellspacing="0" cellpadding="0" style="height 40px;" id="justbought'.$row.'"><tr><td class=smallText align=center>'.BOX_TEXT_JUSTBOUGHT . '</td></tr>'. '<tr><td>'.tep_draw_separator('pixel_trans.gif', '100%', '3').'</td></tr>'. '<tr><td>'.tep_draw_separator('pixel_blue.gif', '100%', '1').'</td></tr>'. '<tr><td>'.tep_draw_separator('pixel_trans.gif', '100%', '8').'</td></tr>'. '<tr><td class=smallText align=center><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product["products_id"]) . '">' . tep_image(DIR_WS_IMAGES . $product['products_image'], $product['products_name'], SMALL_IMAGE_WIDTH*0.7, SMALL_IMAGE_HEIGHT*0.7) . '</a></td></tr>'. '<tr><td>'.tep_draw_separator('pixel_trans.gif', '100%', '3').'</td></tr>'. '<tr><td class=smallText align=center><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product['products_id']) . '"><b>' . $product['products_name'] . "</a><br>" . $product['customers_city'] . " " .$product['customers_country'] .'</b></td></tr></table>'); new info2Box($info_box_contents); echo("\n</td></tr>\n"); } } ?> <!-- justbought_eof //--> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.