Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

New Products Icon


Guest

Recommended Posts

Ahhh, I see. It's not in the categories, but in the subcategories.

 

Please post your includes/modules/product_listing.php.

 

You added $today_time = time(); to the top of your product_listing.php, right?

 

-jared

Link to comment
Share on other sites

  • Replies 123
  • Created
  • Last Reply

Top Posters In This Topic

This comes from http://www.popthetop.com

 

All seems to work great, except when I do a search for a product. See screen shot below...

 

This is the catagory display, displaying the new icon correctly. Notice that the Van-Pan Drip Catch Pan is NOT new? Well, that IS correct.

 

screen-1.jpg

 

 

Now take a look at the screen shot below to see what happens when I do a simple search for "Van-Pan Drip Catch Pan". As you can see, it shows it as new and it is NOT new.

 

screen-2.jpg

 

 

 

Any ideas?

In fact, the simple search and the advanced search shows ALL items in the search results as new no matter if they are new or not.

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

fixed.  In catalog/advanced_search_result.php, change this:
 $select_str = "select distinct " . $select_column_list . " m.manufacturers_id, p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price ";

 

to this:

$select_str = "select distinct " . $select_column_list . " m.manufacturers_id, p.products_date_added, p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price ";

 

The problem was that catalog/advanced_search_result.php calls catalog/includes/modules/product_listing.php, but since the actual sql query is not in product_listing.php, it's in advanced_search.php, we needed to add the p.products_date_added field to the query.  The code in product_listing.php wasn't getting the products_date_added field, so it couldn't calculate when the product had been added to the store.

 

I'll wait a week or so to see if anyone else comes up with something that needs to be changed, then I'll re-release it.

 

-jared

 

This, quoted from this thread, should fix that. Let me know if it does not fix it.

 

-jared

Link to comment
Share on other sites

I just noticed that the new products icon does not yet show up in the "what's new in December" box at the bottom of index.php. I suspect the same for the "customers who bought this product also purchased" box, which is from a contribution if I remember correctly.

 

I'll work on that tonight, hopefully.

 

-jared

Link to comment
Share on other sites

Ahhh, I see.  It's not in the categories, but in the subcategories.

 

Please post your includes/modules/product_listing.php.

 

You added  $today_time = time(); to the top of your product_listing.php, right?

 

-jared

 

 

Ok Jared, here is my product_listing.php code.

 

<?php
/*
 $Id: product_listing.php,v 1.44 2003/06/09 22:49:43 hpdl Exp $
*/

// added for New Product Icon contribution
 $today_time = time();
// end addition

 $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');

 if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
 <tr>
   <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
   <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
 </tr>
</table>
<?php
 }

 $list_box_contents = array();

 if ($listing_split->number_of_rows > 0) {
   $listing_query = tep_db_query($listing_split->sql_query);

   $row = 0;
   $column = 0;
   while ($listing = tep_db_fetch_array($listing_query)) {

     $product_contents = array();

     for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
       $lc_align = '';

       switch ($column_list[$col]) {
         case 'PRODUCT_LIST_MODEL':
           $lc_align = '';
           $lc_text = ' ' . $listing['products_model'] . ' ';
           break;
         case 'PRODUCT_LIST_NAME':
         // added for New Product Icon contribution
              //  2592000 = 30 days in the unix timestamp format
              if ( ($today_time - strtotime($listing['products_date_added'])) < 2592000) {
                 $listing['products_name'] .= ' <img src="images/icon_newarrival.gif" alt="new product" border="0">';
              }
           // end addition
           $lc_align = '';
           if (isset($HTTP_GET_VARS['manufacturers_id'])) {
             $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';
           } else {
             $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a> ';
           }
           break;
         case 'PRODUCT_LIST_MANUFACTURER':
           $lc_align = '';
           $lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a> ';
           break;
         case 'PRODUCT_LIST_PRICE':
           $lc_align = 'right';
           if (tep_get_products_special_price($listing['products_id'])) {
             $lc_text = ' <s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price(tep_get_products_special_price($listing['products_id']), tep_get_tax_rate($listing['products_tax_class_id'])) . '</span> ';
           } else {
             $lc_text = ' ' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . ' ';
           }
           break;
         case 'PRODUCT_LIST_QUANTITY':
           $lc_align = 'right';
           $lc_text = ' ' . $listing['products_quantity'] . ' ';
           break;
         case 'PRODUCT_LIST_WEIGHT':
           $lc_align = 'right';
           $lc_text = ' ' . $listing['products_weight'] . ' ';
           break;
         case 'PRODUCT_LIST_IMAGE':
           $lc_align = 'center';
           if (isset($HTTP_GET_VARS['manufacturers_id'])) {
             $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
           } else {
             $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';
           }
           break;
         case 'PRODUCT_LIST_BUY_NOW':
           $lc_align = 'center';
           $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
           break;
       }
       $product_contents[] = $lc_text;

     }
     $lc_text = implode('<br>', $product_contents);
     $list_box_contents[$row][$column] = array('align' => 'center',
                                               'params' => 'class="productListing-data"',
                                               'text'  => $lc_text);
     $column ++;
     if ($column >= 3) {
       $row ++;
       $column = 0;
     }
   }

   new productListingBox($list_box_contents);
 } else {
   $list_box_contents = array();

   $list_box_contents[0] = array('params' => 'class="productListing-odd"');
   $list_box_contents[0][] = array('params' => 'class="productListing-data"',
                                  'text' => TEXT_NO_PRODUCTS);

   new productListingBox($list_box_contents);
 }

 if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
 <tr>
   <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
   <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
 </tr>
</table>
<?php
 }
?>

 

 

Hope that helps! Thanks!!!

Link to comment
Share on other sites

I think I found what is going on. I think it's not in product_listing.php, but rather in your index.php. Step 2 in the readme says tomodify 4 queries in index.php. I'm guessing you just modified 2 or 3 of them.

 

Will you go check, please?

 

Thanks!

 

-jared

Link to comment
Share on other sites

By the way, the search results are now correct. Thanks DooD!

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

I think I found what is going on.  I think it's not in product_listing.php, but rather in your index.php.  Step 2 in the readme says tomodify 4 queries in index.php.  I'm guessing you just modified 2 or 3 of them.

 

Will you go check, please?

 

Thanks!

 

-jared

 

 

Oh, that is very possible. I might have missed that step! I'll check it out & let you know a little later! Thanks for the quick response!!!

Link to comment
Share on other sites

Well, I didnt' modify the other instances, and everything seems to be working great now! I'll let you know if I find anything else!

 

Thanks again for the great contribution!

Link to comment
Share on other sites

Fantastic contribution! I played around with it a bit and i had it easily integrated into my store, which is a very much enhanced MS2, including the BTS etc. Everything works fine for me, but then i got an Idea for a further enhancement of this contrib. What if it would be possible to pass the duration for the period, in which the "New" icon showes up, in a variable? Since i am not really a programmer, i had difficulties to set up another time period. I imagine the following:

$newdays = 30;
$period = showmethewaytoconvertinunixtimestamp($newdays);
if ( ($today_time - strtotime($products_new['products_date_added']) ) < $period)      {  ...

I am running a store for preprinted products which can be personalized by the customer, I would like to define products as new for at least 90 days or even more.

Any help with this? I allready spent a few hours googling and trying ...

Thank you :thumbsup:

Link to comment
Share on other sites

I just found a new problem. Go to http://www.popthetop.com/catalog/advanced_...php?keywords=On to see it.

 

It seems that when you do a search with the word "on", it messes everything up.

 

Try a simple search for "On Demand Hot Water Heater" and you will see the problem.

 

Then do a simple search for "Demand Hot Water Heater" or "Hot Water" and you will see that the search results are fine.

 

Any ideas???

 

here is a copy of my advanced_search_results.php

<?php
/*
 $Id: advanced_search_result.php,v 1.72 2003/06/23 06:50:11 project3000 Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

// Search enhancement mod start
 if(isset($_GET['keywords']) && $_GET['keywords'] != ''){
 if(!isset($_GET['s'])){
     $pwstr_check = strtolower(substr($_GET['keywords'], strlen($_GET['keywords'])-1, strlen($_GET['keywords'])));
     if($pwstr_check == 's'){
       $pwstr_replace = substr($_GET['keywords'], 0, strlen($_GET['keywords'])-1);
       header('location: ' . tep_href_link( FILENAME_ADVANCED_SEARCH_RESULT , 'search_in_description=1&s=1&keywords=' . urlencode($pwstr_replace) . '' ));
       exit;
     }
   }

   $pw_keywords = explode(' ',stripslashes(strtolower($_GET['keywords'])));
   $pw_boldwords = $pw_keywords;
   $sql_words = tep_db_query("SELECT * FROM searchword_swap");
   $pw_replacement = '';
   while ($sql_words_result = tep_db_fetch_array($sql_words)) {
     if(stripslashes(strtolower($_GET['keywords'])) == stripslashes(strtolower($sql_words_result['sws_word']))){
       $pw_replacement = stripslashes($sql_words_result['sws_replacement']);
       $pw_link_text = '<b>' . stripslashes($sql_words_result['sws_replacement']) . '</b>';
       $pw_phrase = 1;
       $pw_mispell = 1;
       break;
     }
     for($i=0; $i<sizeof($pw_keywords); $i++){
        if($pw_keywords[$i]  == stripslashes(strtolower($sql_words_result['sws_word']))){
          $pw_keywords[$i]  = stripslashes($sql_words_result['sws_replacement']);
          $pw_boldwords[$i] = '<b><i>' . stripslashes($sql_words_result['sws_replacement']) . '</i></b>';
          $pw_mispell = 1;
          break;
       }
     }
   }
   if(!isset($pw_phrase)){
     for($i=0; $i<sizeof($pw_keywords); $i++){
        $pw_replacement .= $pw_keywords[$i]. ' ';
        $pw_link_text   .= $pw_boldwords[$i]. ' ';	
     }
   }

   $pw_replacement = trim($pw_replacement);
   $pw_link_text   = trim($pw_link_text);
   $pw_string      = '<span class="genblack">' . TEXT_REPLACEMENT_SUGGESTION . '<STRONG><a href="' . tep_href_link( FILENAME_ADVANCED_SEARCH_RESULT , 'keywords=' . urlencode($pw_replacement) . '&search_in_description=1' ) . '">' . $pw_link_text . '</a></STRONG></span><br><br>';
}
// Search enhancement mod end

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADVANCED_SEARCH);

 $error = false;

 if ( (isset($HTTP_GET_VARS['keywords']) && empty($HTTP_GET_VARS['keywords'])) &&
      (isset($HTTP_GET_VARS['dfrom']) && (empty($HTTP_GET_VARS['dfrom']) || ($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING))) &&
      (isset($HTTP_GET_VARS['dto']) && (empty($HTTP_GET_VARS['dto']) || ($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING))) &&
      (isset($HTTP_GET_VARS['pfrom']) && !is_numeric($HTTP_GET_VARS['pfrom'])) &&
      (isset($HTTP_GET_VARS['pto']) && !is_numeric($HTTP_GET_VARS['pto'])) ) {
   $error = true;

   $messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT);
 } else {
   $dfrom = '';
   $dto = '';
   $pfrom = '';
   $pto = '';
   $keywords = '';

   if (isset($HTTP_GET_VARS['dfrom'])) {
     $dfrom = (($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING) ? '' : $HTTP_GET_VARS['dfrom']);
   }

   if (isset($HTTP_GET_VARS['dto'])) {
     $dto = (($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING) ? '' : $HTTP_GET_VARS['dto']);
   }

   if (isset($HTTP_GET_VARS['pfrom'])) {
     $pfrom = $HTTP_GET_VARS['pfrom'];
   }

   if (isset($HTTP_GET_VARS['pto'])) {
     $pto = $HTTP_GET_VARS['pto'];
   }

   if (isset($HTTP_GET_VARS['keywords'])) {
     $keywords = $HTTP_GET_VARS['keywords'];
   }

   $date_check_error = false;
   if (tep_not_null($dfrom)) {
     if (!tep_checkdate($dfrom, DOB_FORMAT_STRING, $dfrom_array)) {
       $error = true;
       $date_check_error = true;

       $messageStack->add_session('search', ERROR_INVALID_FROM_DATE);
     }
   }

   if (tep_not_null($dto)) {
     if (!tep_checkdate($dto, DOB_FORMAT_STRING, $dto_array)) {
       $error = true;
       $date_check_error = true;

       $messageStack->add_session('search', ERROR_INVALID_TO_DATE);
     }
   }

   if (($date_check_error == false) && tep_not_null($dfrom) && tep_not_null($dto)) {
     if (mktime(0, 0, 0, $dfrom_array[1], $dfrom_array[2], $dfrom_array[0]) > mktime(0, 0, 0, $dto_array[1], $dto_array[2], $dto_array[0])) {
       $error = true;

       $messageStack->add_session('search', ERROR_TO_DATE_LESS_THAN_FROM_DATE);
     }
   }

   $price_check_error = false;
   if (tep_not_null($pfrom)) {
     if (!settype($pfrom, 'double')) {
       $error = true;
       $price_check_error = true;

       $messageStack->add_session('search', ERROR_PRICE_FROM_MUST_BE_NUM);
     }
   }

   if (tep_not_null($pto)) {
     if (!settype($pto, 'double')) {
       $error = true;
       $price_check_error = true;

       $messageStack->add_session('search', ERROR_PRICE_TO_MUST_BE_NUM);
     }
   }

   if (($price_check_error == false) && is_float($pfrom) && is_float($pto)) {
     if ($pfrom >= $pto) {
       $error = true;

       $messageStack->add_session('search', ERROR_PRICE_TO_LESS_THAN_PRICE_FROM);
     }
   }

   if (tep_not_null($keywords)) {
     if (!tep_parse_search_string($keywords, $search_keywords)) {
       $error = true;

       $messageStack->add_session('search', ERROR_INVALID_KEYWORDS);
     }
   }
 }

 if (empty($dfrom) && empty($dto) && empty($pfrom) && empty($pto) && empty($keywords)) {
   $error = true;

   $messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT);
 }

 if ($error == true) {
   tep_redirect(tep_href_link(FILENAME_ADVANCED_SEARCH, tep_get_all_get_params(), 'NONSSL', true, false));
 }

// Search enhancement mod start
 $search_enhancements_keywords = $_GET['keywords'];
 $search_enhancements_keywords = strip_tags($search_enhancements_keywords);
 $search_enhancements_keywords = addslashes($search_enhancements_keywords);

 if ($search_enhancements_keywords != $last_search_insert) {
   tep_db_query("insert into search_queries (search_text)  values ('" .  $search_enhancements_keywords . "')");
   tep_session_register('last_search_insert');
   $last_search_insert = $search_enhancements_keywords;
 }
// Search enhancement mod end

 $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ADVANCED_SEARCH));
 $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, tep_get_all_get_params(), 'NONSSL', true, false));
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE_2; ?></td>
           <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_browse.gif', HEADING_TITLE_2, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td>
<?php
// create column list
 $define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,
                      'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
                      'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,
                      'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,
                      'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
                      'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,
                      'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE,
                      'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);

 asort($define_list);

 $column_list = array();
 reset($define_list);
 while (list($key, $value) = each($define_list)) {
   if ($value > 0) $column_list[] = $key;
 }

 $select_column_list = '';

 for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
   switch ($column_list[$i]) {
     case 'PRODUCT_LIST_MODEL':
       $select_column_list .= 'p.products_model, ';
       break;
     case 'PRODUCT_LIST_MANUFACTURER':
       $select_column_list .= 'm.manufacturers_name, ';
       break;
     case 'PRODUCT_LIST_QUANTITY':
       $select_column_list .= 'p.products_quantity, ';
       break;
     case 'PRODUCT_LIST_IMAGE':
       $select_column_list .= 'p.products_image, ';
       break;
     case 'PRODUCT_LIST_WEIGHT':
       $select_column_list .= 'p.products_weight, ';
       break;
   }
 }

 $select_str = "select distinct " . $select_column_list . " m.manufacturers_id, p.products_date_added, p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price ";
 if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
   $select_str .= ", SUM(tr.tax_rate) as tax_rate ";
 }

 $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";

 if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
   if (!tep_session_is_registered('customer_country_id')) {
     $customer_country_id = STORE_COUNTRY;
     $customer_zone_id = STORE_ZONE;
   }
   $from_str .= " left join " . TABLE_TAX_RATES . " tr on p.products_tax_class_id = tr.tax_class_id left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int)$customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int)$customer_zone_id . "')";
 }

 $where_str = " where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id ";

 if (isset($HTTP_GET_VARS['categories_id']) && tep_not_null($HTTP_GET_VARS['categories_id'])) {
   if (isset($HTTP_GET_VARS['inc_subcat']) && ($HTTP_GET_VARS['inc_subcat'] == '1')) {
     $subcategories_array = array();
     tep_get_subcategories($subcategories_array, $HTTP_GET_VARS['categories_id']);

     $where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and (p2c.categories_id = '" . (int)$HTTP_GET_VARS['categories_id'] . "'";

     for ($i=0, $n=sizeof($subcategories_array); $i<$n; $i++ ) {
       $where_str .= " or p2c.categories_id = '" . (int)$subcategories_array[$i] . "'";
     }

     $where_str .= ")";
   } else {
     $where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['categories_id'] . "'";
   }
 }

 if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
   $where_str .= " and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
 }

 if (isset($search_keywords) && (sizeof($search_keywords) > 0)) {
   $where_str .= " and (";
   for ($i=0, $n=sizeof($search_keywords); $i<$n; $i++ ) {
     switch ($search_keywords[$i]) {
       case '(':
       case ')':
       case 'and':
       case 'or':
         $where_str .= " " . $search_keywords[$i] . " ";
         break;
       default:
         $keyword = tep_db_prepare_input($search_keywords[$i]);
         $where_str .= "(pd.products_name like '%" . tep_db_input($keyword) . "%' or p.products_model like '%" . tep_db_input($keyword) . "%' or m.manufacturers_name like '%" . tep_db_input($keyword) . "%'";
         if (isset($HTTP_GET_VARS['search_in_description']) && ($HTTP_GET_VARS['search_in_description'] == '1')) $where_str .= " or pd.products_description like '%" . tep_db_input($keyword) . "%'";
         $where_str .= ')';
         break;
     }
   }
   $where_str .= " )";
 }

 if (tep_not_null($dfrom)) {
   $where_str .= " and p.products_date_added >= '" . tep_date_raw($dfrom) . "'";
 }

 if (tep_not_null($dto)) {
   $where_str .= " and p.products_date_added <= '" . tep_date_raw($dto) . "'";
 }

 if (tep_not_null($pfrom)) {
   if ($currencies->is_set($currency)) {
     $rate = $currencies->get_value($currency);

     $pfrom = $pfrom / $rate;
   }
 }

 if (tep_not_null($pto)) {
   if (isset($rate)) {
     $pto = $pto / $rate;
   }
 }

 if (DISPLAY_PRICE_WITH_TAX == 'true') {
   if ($pfrom > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) >= " . (double)$pfrom . ")";
   if ($pto > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) <= " . (double)$pto . ")";
 } else {
   if ($pfrom > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) >= " . (double)$pfrom . ")";
   if ($pto > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) <= " . (double)$pto . ")";
 }

 if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
   $where_str .= " group by p.products_id, tr.tax_priority";
 }

 if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {
   for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
     if ($column_list[$i] == 'PRODUCT_LIST_NAME') {
       $HTTP_GET_VARS['sort'] = $i+1 . 'a';
       $order_str = ' order by pd.products_name';
       break;
     }
   }
 } else {
   $sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1);
   $sort_order = substr($HTTP_GET_VARS['sort'], 1);
   $order_str = ' order by ';
   switch ($column_list[$sort_col-1]) {
     case 'PRODUCT_LIST_MODEL':
       $order_str .= "p.products_model " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
       break;
     case 'PRODUCT_LIST_NAME':
       $order_str .= "pd.products_name " . ($sort_order == 'd' ? "desc" : "");
       break;
     case 'PRODUCT_LIST_MANUFACTURER':
       $order_str .= "m.manufacturers_name " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
       break;
     case 'PRODUCT_LIST_QUANTITY':
       $order_str .= "p.products_quantity " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
       break;
     case 'PRODUCT_LIST_IMAGE':
       $order_str .= "pd.products_name";
       break;
     case 'PRODUCT_LIST_WEIGHT':
       $order_str .= "p.products_weight " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
       break;
     case 'PRODUCT_LIST_PRICE':
       $order_str .= "final_price " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
       break;
   }
 }

 $listing_sql = $select_str . $from_str . $where_str . $order_str;

 require(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING);
?>
       </td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH, tep_get_all_get_params(array('sort', 'page')), 'NONSSL', true, false) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
     </tr>
   </table></td>
<!-- body_text_eof //-->
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
   </table></td>
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

I just found a new problem. Go to http://www.popthetop.com/catalog/advanced_...php?keywords=On to see it.

 

It seems that when you do a search with the word "on", it messes everything up.

 

Try a simple search for "On Demand Hot Water Heater" and you will see the problem.

 

Then do a simple search for "Demand Hot Water Heater" or "Hot Water" and you will see that the search results are fine.

 

Any ideas???

 

 

For me it works fine, nothing gets messed up. But if I do a search with the word "on", the results are all products, which contain the new-icon. This is probably because the image Tag becomes part of the product name. So if you search "on", you will allways get a match, the product name contains icon_newarrival.gif. Maybe a renaming of the image into something cryptical like hasfdwae.gif will fix that, i'll check that later.

Link to comment
Share on other sites

Wow, you are correct. I renamed it neu.gif and now it all works fine. Thanks!!!!!!

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

Fantastic contribution! I played around with it a bit and i had it easily integrated into my store, which is a very much enhanced MS2, including the BTS etc. Everything works fine for me, but then i got an Idea for a further enhancement of this contrib. What if it would be possible to pass the duration for the period, in which the "New" icon showes up, in a variable? Since i am not really a programmer, i had difficulties to set up another time period. I imagine the following:

$newdays = 30;
$period = showmethewaytoconvertinunixtimestamp($newdays);
if ( ($today_time - strtotime($products_new['products_date_added']) ) < $period)      {  ...

I am running a store for preprinted products which can be personalized by the customer, I  would like to define products as new for at least 90 days or even more.

Any help with this? I allready spent a few hours googling and trying ...

Thank you  :thumbsup:

 

1 day in unix time is equivalent to 86400. Therefore, if you want to have a variable of days, just multiply the number of days by 86400.

 

An alternate way to do it, perhaps a better way, would be to use the TO_DAYS function as follows:

$days_of_new_products = 30;
if ( TO_DAYS(NOW()) - TO_DAYS($products_new['products_date_added']) < $days_of_new_products )
{ print the icon
}

 

Don't give me credit for it, it's from one of the other threads on how to fix the products_new.php so that it only shows 30/60/90/whatever day's worth of products instead of *all* products (i.e. how to make it work nearly as intended).

 

-jared

Link to comment
Share on other sites

Odd, I don't have that problem.  My image is also called icon_newarrival.gif.

 

-jared

 

 

Do you have the "Search Results with Highlight v1.1" installed?

I do...

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

@pop:

Looks good now, your results page :thumbsup: . Seems that the Search Highlight Contrib would fit into my Store also, i think i will add it soon!

 

@jared: That was exactly what i needed! Big THX 4 HLP !!! :lol:

 

Yeah, i love this masterpiece of script. OSC rulez... I am learning something new every day ...

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...