Dragonmom Posted January 13, 2004 Share Posted January 13, 2004 Because my people tend to make one of a thing- one rose quartz necklace, say- but many necklaces, i want to change the product notifications box. I want it to notify people of changes to the category the item is listed in. Similarly, I want the reviews to link to the category, as once an item is gone, it's gone. Here is the notifications box; If I am right, I have to link the product id withthe category id? How do i do that? <?php/* $Id: product_notifications.php,v 1.8 2003/06/09 22:19:07 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ if (isset($HTTP_GET_VARS['products_id'])) { ?> <!-- notifications //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_NOTIFICATIONS); new infoBoxHeading($info_box_contents, false, false, tep_href_link(FILENAME_ACCOUNT_NOTIFICATIONS, '', 'SSL')); if (tep_session_is_registered('customer_id')) { $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and customers_id = '" . (int)$customer_id . "'"); $check = tep_db_fetch_array($check_query); $notification_exists = (($check['count'] > 0) ? true : false); } else { $notification_exists = false; } $info_box_contents = array(); if ($notification_exists == true) { $info_box_contents[] = array('text' => '<table border="0" cellspacing="0" cellpadding="2"><tr><td class="infoBoxContents"><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=notify_remove', $request_type) . '">' . tep_image(DIR_WS_IMAGES . 'box_products_notifications_remove.gif', IMAGE_BUTTON_REMOVE_NOTIFICATIONS) . '</a></td><td class="infoBoxContents"><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=notify_remove', $request_type) . '">' . sprintf(BOX_NOTIFICATIONS_NOTIFY_REMOVE, tep_get_products_name($HTTP_GET_VARS['products_id'])) .'</a></td></tr></table>'); } else { $info_box_contents[] = array('text' => '<table border="0" cellspacing="0" cellpadding="2"><tr><td class="infoBoxContents"><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">' . tep_image(DIR_WS_IMAGES . 'box_products_notifications.gif', IMAGE_BUTTON_NOTIFICATIONS) . '</a></td><td class="infoBoxContents"><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">' . sprintf(BOX_NOTIFICATIONS_NOTIFY, tep_get_products_name($HTTP_GET_VARS['products_id'])) .'</a></td></tr></table>'); } new infoBox($info_box_contents); ?> </td> </tr> <!-- notifications_eof //--> <?php } ?> similarly, in reviews.php <?php/* $Id: reviews.php,v 1.37 2003/06/09 22:20:28 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ ?> <!-- reviews //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_REVIEWS); new infoBoxHeading($info_box_contents, false, false, tep_href_link(FILENAME_REVIEWS)); $random_select = "select r.reviews_id, r.reviews_rating, p.products_id, p.products_image, pd.products_name from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd, " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = r.products_id and r.reviews_id = rd.reviews_id and rd.languages_id = '" . (int)$languages_id . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'"; if (isset($HTTP_GET_VARS['products_id'])) { $random_select .= " and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'"; } $random_select .= " order by r.reviews_id desc limit " . MAX_RANDOM_SELECT_REVIEWS; $random_product = tep_random_select($random_select); $info_box_contents = array(); if ($random_product) { // display random review box $review_query = tep_db_query("select substring(reviews_text, 1, 60) as reviews_text from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . (int)$random_product['reviews_id'] . "' and languages_id = '" . (int)$languages_id . "'"); $review = tep_db_fetch_array($review_query); $review = tep_break_string(tep_output_string_protected($review['reviews_text']), 15, '-<br>'); $info_box_contents[] = array('text' => '<div align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_INFO, 'products_id=' . $random_product['products_id'] . '&reviews_id=' . $random_product['reviews_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></div><a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_INFO, 'products_id=' . $random_product['products_id'] . '&reviews_id=' . $random_product['reviews_id']) . '">' . $review . ' ..</a><br><div align="center">' . tep_image(DIR_WS_IMAGES . 'stars_' . $random_product['reviews_rating'] . '.gif' , sprintf(BOX_REVIEWS_TEXT_OF_5_STARS, $random_product['reviews_rating'])) . '</div>'); } elseif (isset($HTTP_GET_VARS['products_id'])) { // display 'write a review' box $info_box_contents[] = array('text' => '<table border="0" cellspacing="0" cellpadding="2"><tr><td class="infoBoxContents"><a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, 'products_id=' . $HTTP_GET_VARS['products_id']) . '">' . tep_image(DIR_WS_IMAGES . 'box_write_review.gif', IMAGE_BUTTON_WRITE_REVIEW) . '</a></td><td class="infoBoxContents"><a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, 'products_id=' . $HTTP_GET_VARS['products_id']) . '">' . BOX_REVIEWS_WRITE_REVIEW .'</a></td></tr></table>'); } else { // display 'no reviews' box $info_box_contents[] = array('text' => BOX_REVIEWS_NO_REVIEWS); } new infoBox($info_box_contents); ?> </td> </tr> <!-- reviews_eof //--> psst... wanna buy a wand? Link to comment Share on other sites More sharing options...
♥kymation Posted January 13, 2004 Share Posted January 13, 2004 Linking the product to the category is just a matter of querying the database. Use this: <?php $categories_name_query = tep_db_query("select c.categories_name, c.categories_id from " . TABLE_CATEGORIES_DESCRIPTION . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " pcat where pcat.categories_id = c.categories_id and pcat.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'"); $categories_name = tep_db_fetch_array($categories_name_query); ?> Now you can use $categories_name['categories_id'] for the ID number of the category and $categories_name['categories_name'] for the name of the category. I did something similar on an osC site, but I gave the customer a chance to pick notification for any category. The theory was that they might be interested in something that they were not purchasing right now. Of course this would not work if your store has a large number of categories. Regards Jim See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
Dragonmom Posted January 14, 2004 Author Share Posted January 14, 2004 Thanks, Jim, but i don't know where to put that code... I'm a designer, not a programmer, and not even as much a designer as I am a woodworker ;) psst... wanna buy a wand? Link to comment Share on other sites More sharing options...
Dragonmom Posted January 15, 2004 Author Share Posted January 15, 2004 mmm... hello? psst... wanna buy a wand? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.