Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

New Products Icon


Guest

Recommended Posts

New Products Icon 1.0

Dec 04, 2004

Authors: Jared Call, Bobby

 

Credit to Chemo (Bobby) for showing me how to condense some of this code

 

 

What this contrib does:

=========================

In both the New Products listing and the regular catalog listing, this contribution adds a "new" icon next to the product's name if the product was added to your store within the past 30 days.

 

Disclaimer: This contrib has been designed for and tested with osCommerce 2.2 MS2. While it should easily work, perhaps with minor modifications, with other versions of osCommerce, it has not been tested as such.

 

BACK UP FIRST!

 

Downloadable from http://www.oscommerce.com/community/contributions,2690

Edited by jcall
Link to comment
Share on other sites

  • Replies 123
  • Created
  • Last Reply

Top Posters In This Topic

New Products Icon 1.0

Dec 04, 2004

Authors:  Jared Call, Bobby

 

Credit to Chemo (Bobby) for showing me how to condense some of this code

What this contrib does:

=========================

In both the New Products listing and the regular catalog listing, this contribution adds a "new" icon next to the product's name if the product was added to your store within the past 30 days.

 

Disclaimer:  This contrib has been designed for and tested with osCommerce 2.2 MS2.  While it should easily work, perhaps with minor modifications, with other versions of osCommerce, it has not been tested as such.

 

BACK UP FIRST!

 

Downloadable from http://www.oscommerce.com/community/contributions,2690

 

The only problem I've experienced so far is that when you do a search (I use Advanced Search Infobox v1.00), everything listed on the search results page is "new".

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

Edited by jcall
Link to comment
Share on other sites

I'm probably missing something here Jared but wouldn' it be better to treat a product as not new unless told otherwise?

 

It seems from your last post that the logic at present is to assume all products are new unless you can find a date which tells you otherwise. Since at least 90% of products in a typical store are going to be old , wouldn't it make sense to assume they are unless told otherwise?

 

That way hopefully there would be one less file to change.

Link to comment
Share on other sites

Nope. The key code is as follows:

            // 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 for New Product Icon contribution

 

As you can see, the logic is that all products are old unless they were added over 30 days ago.

 

The problem is that if this code gets called with a query that has not retrieved the products_date_added field from the database, then the value for this field will be assumed to be zero. Since zero is always less than 30 days, it will get the new icon. That's what was happening with the advanced_search_result.php.

 

You can't tell how old something is without looking at the products_date_added field.

 

-jared

Link to comment
Share on other sites

hi jared

 

nice contrib, i got it working with no problems at all. Just a quick question, any idea how you can change the position of the icon. At the moment i think it is positioned top is it easy to change to bottom, or am i talking rubbish here?

Link to comment
Share on other sites

I can not open the ZIP file that I download from http://www.oscommerce.com/community/contributions,2690

 

It states there is something wrong with it and that there is an error in the ZIP.

 

Please upload a new copy at http://www.oscommerce.com/community/contributions,2690 with the bug fix from above added in.

Edited by PopTheTop

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 downloaded it from the Americas mirror, extracted just fine. Looks like it worked fine for Mighty Mike as well as baddog.

 

Please try the download again, or try a different archive utility.

 

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

Link to comment
Share on other sites

it works fine but with one problem:

 

in product_new.php when listing pictures they have inside alt tag <img src="images/icon_newarrival.gif" alt="something..." border="0"> becase of the way this page is hacked.

Is there any other way?

I have no idee-a how to correct this?

I can't belliewe that nobody noticed that?!?

 

respect

 

V'gor A.K.A. CrNi

 

zee

 

http://www.times.hr/shop/products_new.php

Link to comment
Share on other sites

it works fine but with one problem:

 

in product_new.php when listing pictures they have inside alt tag <img src="images/icon_newarrival.gif" alt="something..." border="0"> becase of the way this page is hacked.

Is there any other way?

I have no idee-a how to correct this?

I can't belliewe that nobody noticed that?!?

 

respect

 

V'gor A.K.A. CrNi

 

zee

 

http://www.times.hr/shop/products_new.php

My alt tag reads "New". That's perfect as far as I'm concerned. Either that or just delete the alt tag.

Link to comment
Share on other sites

oh yeah, i have just noticed this also, when you hover over the "icon image" the alt tag is "new" but when you hover over the product image it is the product name followed by "<img src="images/icon_newarrival.gif" alt="new" border="0">"

 

Any ideas on how to fix this?

Link to comment
Share on other sites

Tried it again and all is working. Thanks though...

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

oh yeah, i have just noticed this also, when you hover over the "icon image" the alt tag is "new" but when you hover over the product image it is the product name followed by "<img src="images/icon_newarrival.gif" alt="new" border="0">"

 

Any ideas on how to fix this?

That's really strange. I usually use Firefox so I don't see those. I pulled mine up in IE and it actually says "New Product" if I hover over the "new" gif but if I hover over the product picture, I get the product name (in other words, I don't get the code you see on yours). Very strange.

Link to comment
Share on other sites

Yep, mine too. Take a look at http://www.popthetop.com/catalog/products_new.php and you will see.

 

But I may just remove that from products_new.php because you really do not need it there. After all, that IS the New Products listing so people will already know it is new.

 

=============

 

Anyway... I have another problem, it does not list in the catagory listing of products. I have the MOD installed that highlights the searched keywords. The code in index.php is a bit different so I am hoping someone can help me get it installed there correctly.

 

Here is my code in product_listing.php...

        switch ($column_list[$col]) {
// Highlight search results MOD
         case 'PRODUCT_LIST_MODEL':
   $fldname = $listing['products_model'];
   if ($HTTP_GET_VARS['keywords'] != "" ) {
  	 $HTTP_GET_VARS['keywords'] = strtolower($HTTP_GET_VARS['keywords']);
  	 $string_to_split = strtoupper($HTTP_GET_VARS['keywords']); // is result UPPERCASE ?
  	 $tok = split(" ", $string_to_split);
  	 $size = sizeof($tok);
  	 for ($i = 0; $i < $size; $i++) 
  	 $fldname = str_replace($tok[$i], '<span style="background-color: ' . SEARCH_RESULT_BACKGROUND_COLOR . '">' . $tok[$i] . '</span>', $fldname);

  	 $string_to_split = $HTTP_GET_VARS['keywords']; // is result LOWERCASE ?
  	 $tok = split(" ", $string_to_split);
  	 $size = sizeof($tok);
  	 for ($i = 0; $i < $size; $i++) 
  	 $fldname = str_replace($tok[$i], '<span style="background-color: ' . SEARCH_RESULT_BACKGROUND_COLOR . '">' . $tok[$i] . '</span>', $fldname);

  	 $string_to_split = ucwords($HTTP_GET_VARS['keywords']); // is result starting with 1 uppercase and rest is lowercase ?
  	 $tok = split(" ", $string_to_split);
  	 $size = sizeof($tok);
  	 for ($i = 0; $i < $size; $i++) 
  	 $fldname = str_replace($tok[$i], '<span style="background-color: ' . SEARCH_RESULT_BACKGROUND_COLOR . '">' . $tok[$i] . '</span>', $fldname); 
   }          
           $lc_align = '';
           $lc_text = ' ' . $fldname . ' ';
           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="" border="0">';
           }
           // end addition
           if ($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'], 'NONSSL') . '">' . $listing['products_name'] . '</a>';
           } else {
  	 $fldname = $listing['products_name'];
  	 if ($HTTP_GET_VARS['keywords'] != "" ) {
     $HTTP_GET_VARS['keywords'] = strtolower($HTTP_GET_VARS['keywords']);
     $string_to_split = strtoupper($HTTP_GET_VARS['keywords']); // is result UPPERCASE ?
     $tok = split(" ", $string_to_split);
     $size = sizeof($tok);
     for ($i = 0; $i < $size; $i++) 
     $fldname = str_replace($tok[$i], '<span style="background-color: ' . SEARCH_RESULT_BACKGROUND_COLOR . '">' . $tok[$i] . '</span>', $fldname);

     $string_to_split = $HTTP_GET_VARS['keywords']; // is result LOWERCASE ?
     $tok = split(" ", $string_to_split);
     $size = sizeof($tok);
     for ($i = 0; $i < $size; $i++) 
     $fldname = str_replace($tok[$i], '<span style="background-color: ' . SEARCH_RESULT_BACKGROUND_COLOR . '">' . $tok[$i] . '</span>', $fldname);

     $string_to_split = ucwords($HTTP_GET_VARS['keywords']); // is result starting with 1 uppercase and rest is lowercase ?
     $tok = split(" ", $string_to_split);
     $size = sizeof($tok);
     for ($i = 0; $i < $size; $i++) 
     $fldname = str_replace($tok[$i], '<span style="background-color: ' . SEARCH_RESULT_BACKGROUND_COLOR . '">' . $tok[$i] . '</span>', $fldname);
  	 }
          	 $lc_align = '';
          	 $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $fldname . '</a> ';
           }
           break;

 

Anyone?

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 trhink I got it. here is where I added it...

 

          case 'PRODUCT_LIST_NAME':
           if ($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'], 'NONSSL') . '">' . $listing['products_name'] . '</a>';
           } else {
              // 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="" border="0">';
              }
              // end addition
  	 $fldname = $listing['products_name'];
  	 if ($HTTP_GET_VARS['keywords'] != "" ) {
     $HTTP_GET_VARS['keywords'] = strtolower($HTTP_GET_VARS['keywords']);
     $string_to_split = strtoupper($HTTP_GET_VARS['keywords']); // is result UPPERCASE ?.....

 

Seems to work.

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

oh yeah, i have just noticed this also, when you hover over the "icon image" the alt tag is "new" but when you hover over the product image it is the product name followed by "<img src="images/icon_newarrival.gif" alt="new" border="0">"

 

Any ideas on how to fix this?

 

 

Well, if you think about it, you do not need the ALT tag calling the item name in the image since the item name is already displayed right next to the image. This is what I did to give this a simple fix... Take out the ALT tag as follows:

 

In products_new.php AND products_listing.php

Look for:

tep_image(DIR_WS_IMAGES . $products_new['products_image'], $products_new['products_name'], 0, 0)

Change to this:

tep_image(DIR_WS_IMAGES . $products_new['products_image'], '', 0, 0)

Edited by PopTheTop

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

Ok, I just installed this contribution & I'm not sure what's going on.

 

What I'm seeing is this - when I click on all products, I'll see the "new" icon only on the newly uploaded products.

 

Now, when I go into my subcategories, I have a the "new" icon everywhere. I'm not sure what I need to change to not have them show up or are they simply giong to disappear after 30 days?

 

Also, I'd love to have the "new" icon show up the What's New section of my shop, but I'm not sure how to modify the code to make it work.

 

Thanks for the great contribution!

Link to comment
Share on other sites

Here's a better solution, IMO. You get to keep the ALT tag, which is better to have it there for search engines, alternate browsers, disabled access, etc, and it actually doesn't look goofy. (FWIW, my products_new is the only place where I see the problem. The ALT tag in my index.php and elsewhere seems ok.)

 

In products_new.php, find this:

        $products_new['products_name'] .= ' <img src="images/icon_newarrival.gif" alt="new product" border="0">';

 

and add this above it:

             $products_alt=$products_new['products_name'];

 

Now, find this:

            <td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $products_new['products_image'], $products_new['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?></td>

 

and change it to this:

            <td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $products_new['products_image'], $products_alt, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?></td>

 

That should keep the tag and de-uglify it.

 

I also realized that this line:

 else       {
       $newprod_products_name = $products_new['products_name'] . '</a>';
     }

is totally useless. It doesn't do anything anymore - - it's from when I was trying to figure it out in the first place.

 

 

Joel - The full instructions specify how to make it work in both products_new.php (the "new products" link) and in the rest of the catalog. Following the entire set of steps, plus the change to advanced_search.php listed above should have it working in the main catalog, subcatalog, search, and what's new.

 

-jared

Edited by jcall
Link to comment
Share on other sites

Ok, I double checked my installation & everything seems to be installed properly.

 

This is what I'm seeing.

Gift Certificate category

Gift Certificate Search

That's the problem that I'm experiencing.

 

 

Hmmm, I see no problems at all, what are you talking about????

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 see that in your advanced_search_results, none have the icon. When I browse to the category, they all have the icon.

 

I checked the $10 certificate - - says it was added on the 31th of July. That's certainly more than 30 days ago (assuming that you've not changed the time code), so I'm assuming that none of them should show the new icon.

 

I poked around a little bit, and it looks like all of the product listings (search, catalog, products_new) are all behaving properly *except* for the Gift Certificates category. Is that the only area where you see this problem?

 

It's very odd that the problem would be limited to only that category - - is there anything else strange or non-standard about that category? I also have CCGV installed, which is where I'm guessing you're getting the gift certificates. I installed it quite a while ago, so it may not be the same version you're running.

 

-jared

Link to comment
Share on other sites

I see that in your advanced_search_results, none have the icon.  When I browse to the category, they all have the icon. 

 

I checked the $10 certificate - - says it was added on the 31th of July.  That's certainly more than 30 days ago (assuming that you've not changed the time code), so I'm assuming that none of them should show the new icon.

 

I poked around a little bit, and it looks like all of the product listings (search, catalog, products_new) are all behaving properly *except* for the Gift Certificates category.  Is that the only area where you see this problem?

 

It's very odd that the problem would be limited to only that category - - is there anything else strange or non-standard about that category?  I also have CCGV installed, which is where I'm guessing you're getting the gift certificates.  I installed it quite a while ago, so it may not be the same version you're running.

 

-jared

 

 

well, what i'm seeing is in all the categories, not just limited to the Gift Certificate. The version of the CCGV I'm using is 510b. I think it's the latest version, unless something has changed. I haven't checked. I do have the column contribution installed.... not sure if that has anything to do with.

Link to comment
Share on other sites

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...