About Club osCommerce

Showcasing osCommerce…the good, the bad and the ugly!

Follow osc_pro on Twitter

Featured Products in osCommerce

Written By Gary on Apr 02 2008 · Comments (88) Follow osc_pro on Twitter

One of the very finest things you can do to make your customers experience better is to point them at your special offers and featured products.

In standard osCommerce, the "New Products" box on the first page is pretty useless – it's just a list of the latest 9 products added. My idea is to use that box to show "Featured Products" instead – so I set about finding a cleanly coded solution.

Guess what? I couldn't find one.

Sure, there are a few "featured" contributions, but all of them are rather clunkily coded (including one I made many years ago)! So, I set about recoding a few files to make adding featured products really easy.

Have a look at the video below;

Basically, my idea is to have a "flag" to set the featured status or not (in eaxctly the same way that you use it to set the product in or out of stock). This makes it really easy to set a product featured.

My other thought was to use the existing "New Products" box ratyer than have to code a new one – so I did!

The result is a cleanly coded "Featured Products" contribution that sticks to osCommerce coding convention and is easy to install. Just a few drop-in files if you install a new store, and if you have an existing store, just a few lines of code to add to a few files;

  • /admin/categories.php
  • /admin/includes/languages/english/categories.php (and obviously german etc)
  • /admin/includes/functions/general.php
  • /includes/modules/new_products.php

And that is it! I will zip it up and add it to the contributions area later on.


Buy Gary A Beer?
Buying me a "beer" helps me to keep my contributions updated and keep this blog alive - and you get a link from my homepage to your site. Cheers!


88 Comments

  1. Now available at; http://addons.oscommerce.com/info/5848

    Please note that any and all support is done at this thread – nowhere else. I offer an installation service at $25.00 to $50 (or more, it depends upon what you have installed already) if you cannot manage to install this yourself.

    Only the english language is supplied, if any readers would like to translate the few bits of text, here they are;

    Featured
    Feature in New Products
    Yes
    No

    Please do post your german, french, spanish, polish etc etc translations here, and I will add them into the download. Thanks.

    Comment by Gary — April 2, 2008 @ 11:08 am


  2. Hi, this is my first osc website and your contrib. is just what i was looking for. I do´nt understad WHY this contrib is not standard to osc.

    I could not find a install.txt or instructions on what to ad since my website is already running and i ca´nt just copy/paste files.

    Thanks for the contrib, lloking forward to using it !!!!

    Comment by Gaston — April 2, 2008 @ 1:46 pm


  3. Hi Gaston

    For an already developed store, you'll need to use a program like Beyond Compare – to compare your EXISTING file to my NEW files…

    You'll be able to see the changes really easily. If you cannot manage I offer an installation service at $25 to $50 usd (price depends upon what you have already installed).

    Thanks, Gary

    Comment by Gary — April 2, 2008 @ 2:37 pm


  4. as a new user to oscommerce i was advised to move from RC2a to MS2. Can this be used for MS2?

    Comment by Adam — April 3, 2008 @ 7:21 am


  5. Adam – should work OK in MS2, but I have not tested it.

    Why anyone would advise you to go from RC2a to MS2 though – what was the reason for that?

    Comment by Gary — April 3, 2008 @ 7:25 am


  6. i was @ oscanswers. contributions like Fast Easy Checkout & HTC work, & some of the speed
    optimisation thread is specific to MS2. i will work on both sites and see where
    it takes me … so much to learn

    Comment by Adam — April 3, 2008 @ 3:03 pm


  7. Adam – it is true that some contribs won't work on RC2a – but to be honest, it's not all that many that don't…

    Let us know how you get on.

    Comment by Gary — April 3, 2008 @ 3:08 pm


  8. Hi,
    There is a bug, I tried to upload it to the contribution area but could not as it is locked.

    Go to the link below and you will see the fix, might be an idea for those of you who have installed it to fix the bug and for Burt to update the contribution.
    http://forums.oscommerce.com/index.php?showtopic=298837

    This contribution is amazing, thank you!

    Comment by Richard — April 10, 2008 @ 5:50 pm


  9. Richard – many thanks for spotting that bug. I will update the contribution tomorrow. Cheers!

    Comment by Gary — April 10, 2008 @ 9:40 pm


  10. I have had a few requests for installation. Yes, this is available at a small cost. I need to have the following;

    1. Access to your shop Admin Area.
    2. Access to PHPMyAdmin (usually in the host control panel)
    3. Access to FTP

    If you want to have this installed please email me on oscshops@gmail.com – giving all the above info. I will email you back to let you know my paypal email address.

    DO NOT POST PRIVATE INFO IN THIS BLOG!

    Comment by Gary — April 13, 2008 @ 9:37 am


  11. [...] rather than the last 9 added/amended products. A better option in my opinion would be to add a "Featured Products" contribution, as I think that no customer wants to see Random [...]

    Pingback by Club osCommerce » Random Products on Front Page — April 18, 2008 @ 10:41 am


  12. Struggling to get this installed due to the fact I have a "product sort order add on" already installed. Any pointers would be appreciated.

    many thanks Chris

    Comment by Glosticks — April 21, 2008 @ 9:57 am


  13. Chris – that's the problem with osCommerce unfortunately – contributions tend to make a mess of the base code and so adding furhter contributions is difficult.

    I offer an install service should you not be able to get it up and running. Please email me if you need to have a chat about that and get a price. Gary

    Comment by Gary — April 21, 2008 @ 10:09 am


  14. I installed this feature on fresh installed osc…but the feature settings do not reflect the changes on the index page.

    Comment by mike — April 23, 2008 @ 2:45 am


  15. Mike – you have installed it incorrectly. I offer an install service should you not be able to get it working.

    Comment by Gary — April 23, 2008 @ 6:47 am


  16. Same problem with my friends installation. Fresh installed osc with your feature… but doesn't reflect the change. I am almost done with manual installation file for who wants manual install…but it's useless if the fresh install doesn't even work. Just try it.

    Comment by mike — April 23, 2008 @ 4:29 pm


  17. Mike – strange that many have installed without problems. Very strange ;)

    Would suggest that you are not doing things correctly, wouldn't it?

    Comment by Gary — April 23, 2008 @ 4:48 pm


  18. i'm going to try install in php 5…currently it was tested on php 4.5.

    Comment by mike — April 23, 2008 @ 5:11 pm


  19. Works great – thanks!!

    Comment by jgeoff — April 28, 2008 @ 11:00 pm


  20. Hi, great contribution, got it to work perfectly, many thanks!

    If I may ask, in which order is the products listed within the featured group?
    In the order they was listed as "featured" (1-2-3), on an alphabetical A-B-C basis, or random? Does their home category make any difference on in what order they appear?

    Thanks for your time.

    Comment by Sam — April 29, 2008 @ 3:04 am


  21. jgeoff – thanks for letting me know :)

    Sam – ordered by "date added". So if you have the 9 products in the "new prodcuts" box, and 3 of those are featired, you'd get the first 3 as featured, ordered by date added, then the next 6 would just be the last added products.

    Comment by Gary — April 29, 2008 @ 7:07 am


  22. Thanks for your fast reply Gary. Ah, I see. That makes sense.

    Is there a way to alter the date of a product listed in the database manually?

    Just curious; in some circumstances it could help the design of a front page even further to be able to move a product within the group.

    Comment by Sam — April 29, 2008 @ 3:26 pm


  23. Sam – you should be able to amend the date using phpmyadmin. most likely in the products table, using the products_date_added row

    Comment by Gary — April 29, 2008 @ 4:49 pm


  24. Thanks Gary, will have a look!

    and again, great contribution, just what I have been looking for.
    How much is a beer where you are? :)

    Comment by Sam — April 29, 2008 @ 5:24 pm


  25. Question, and I hope it's not silly, but how do I make it default to "No" when adding new products?

    I tried switching the 0s and 1s here, in /admin/categories.php, but that didn't do it…?

    Comment by jgeoff — April 29, 2008 @ 9:20 pm


  26. jgeoff – find this:

    case '0': $in_featured = false; $out_featured = true; break;
    case '1':
    default: $in_featured = true; $out_featured = false;

    change it to this:

    case '0': $in_featured = false; $out_featured = true; break;
    case '1': $in_featured = true; $out_featured = false; break;
    default: $in_featured = false; $out_featured = true;

    Actually , you found a "bug" – thanks – I'll update the contribution with the new codebase later on today.

    Comment by Gary — April 30, 2008 @ 7:15 am


  27. That works – thanks! :)

    Comment by jgeoff — April 30, 2008 @ 7:29 am


  28. Wait, it doesn't work… it seems everything I add is automatically Featured, before and after this update. Any other ideas, or is it just me?

    Comment by jgeoff — April 30, 2008 @ 7:30 am


  29. Works OK on mine. Must be "just you" ;)

    Comment by Gary — April 30, 2008 @ 7:36 am


  30. LOL The radio button says "No", but after submitting it's still featured… for me. ;)

    Comment by jgeoff — April 30, 2008 @ 7:55 am


  31. Ah well – if you want me to take a look email me your admin and ftp details to oscshops AT gmail DOT com

    Comment by Gary — April 30, 2008 @ 7:58 am


  32. For you it works just fine, after adding a test product and checking your index?

    Comment by jgeoff — April 30, 2008 @ 8:03 am


  33. Yep.

    Comment by Gary — April 30, 2008 @ 8:13 am


  34. I'll contact you tomorrow after I recheck things. For you it's 8:15AM… for me, it's pre-bed 4:15AM lol

    Comment by jgeoff — April 30, 2008 @ 8:17 am


  35. Jgeoff is having a same problem as me. The radio button is "No" but you can still see in index page. I fresh installed last time…but result is the same. I was hoping you can find the bug and let me know.

    Comment by mike — May 7, 2008 @ 7:15 am


  36. There is no bug that causes this – it's user error ;)

    Comment by Gary — May 7, 2008 @ 7:18 am


  37. Works for me too!

    PHP Version: 5.2.0
    Database: MySQL 5.0.27

    Comment by Richard — May 8, 2008 @ 4:53 pm


  38. does your version show products from subcategories?

    Comment by Chris — May 11, 2008 @ 4:13 pm


  39. Chris – in the front page, it shows the products that you selected to be "featured" (regardless of what category or subcategory these featured products are in). On category/subcat pages it does not show featured at all (but can easily be changed to show them) – 1 simple little sql change – no more than 30 seconds extra work. Gary

    Comment by Gary — May 11, 2008 @ 4:48 pm


  40. I copied the downloaded files over my original files (I know, not the best way to do things, but I'm technically challenged). I got an error message on the home page of my store. I thought I copied the original files over the new ones, but now the feature products are working, but the Categories/Products page on the administration website is empty. Everything else about the administration site and the store itself is working, I just can't access the products at all. Any suggestions?

    Comment by Emma — May 27, 2008 @ 1:32 pm


  41. Emma – most certainly not the best way to do things. Make a mirror of your live site on your home or owrk computer and make any changes there first. When happy everyhting works, upload the changed files to your live site. See this for more details. Assuming you have not got a backup, you need to either: Keep working until you find the fix, or pay someone to fix it for you. If you have a backup of you original files, just upload the backup – and then make the changes as per the "already installed" fileset.

    Comment by Gary — May 27, 2008 @ 2:01 pm


  42. I downloaded a copy of Feature Products, however it is a nightmare to install if you have a heavily modified site.
    I like to think I know my way around installing a mod, however this one has no instructions and using winmerge to compared the files is impossible with some files.

    It is referenced in the README.txt and on this page that there is instructions for mod sites to install feature products, however I am unable to find any.

    Is there going to be a instruction manual coming soon? Or even some basic commenting in the code to highlight what has been added.

    I am stuck on the functions/general.php page. everything else was simple. It's just this page light's up like a Christmas tree in winmerge.

    Thanks!

    Comment by Laurence — May 30, 2008 @ 2:34 am


  43. I was able to find out which function is needed from general.php by going step by step through the code.

    The contribution works like a charm!

    Thank you!

    Comment by Laurence — May 30, 2008 @ 2:44 am


  44. Laurence – not too difficult really is it ;)

    Comment by Gary — May 30, 2008 @ 7:39 am


  45. Not if you stop and use your brain!

    Comment by Laurence — June 3, 2008 @ 10:24 am


  46. Am I right in think that the SQL file thats attached in this conrtib needs to be uploaded to your existing database?

    Thanks!

    Comment by aoife — June 23, 2008 @ 3:40 pm


  47. Aoife – that's right :)

    Comment by Gary — June 23, 2008 @ 4:23 pm


  48. Featured Products works great. I had to rely heavily on Beyond Compare.

    Question – I want to display ONLY the products flagged as featured, regardless of whether or not they are new products. What needs to be changed in the SQL (and in what files) to make this work?

    Comment by Charles — June 24, 2008 @ 1:52 pm


  49. Charles – you'd need to play with the new_products module, off the top of my head;

    Find this: where products_status = '1'
    Change to: where products_status = '1' AND p.products_featured = '1'

    Comment by Gary — June 25, 2008 @ 4:18 pm


  50. Thanks Gary! That worked.

    Comment by Charles — June 26, 2008 @ 10:08 am


  51. Hello once again!

    The feature is a charm. Installing it a second time is quite easy. I just went through my personal version and commented the admin/categories.php page where the changes exists – mainly cause my categories.php page is already heavily altered.

    It would be great to see in future updates a page where it displays all the items that has featured set to '1' and then allows you to sort the order.

    Thanks!
    Laurence

    Comment by Laurence — July 4, 2008 @ 3:13 am


  52. Love this.
    One thing tho. I most likely have missed something. How do I change the wording on the box (New Products For July)

    Comment by cassie — July 12, 2008 @ 5:11 am


  53. Deb – good work!

    Cassie – in teh language file for index.php

    Comment by Gary — July 12, 2008 @ 2:32 pm


  54. Oh my goodness *blush*
    Thank you for that. I search and searched where I was to change it and had a feeling it had to be that file. Found it the moment I opened up again to go looking lol.

    Awesome Thank you for your help and all your work :)

    Comment by cassie — July 13, 2008 @ 1:49 am


  55. I have a small problem. This works great on my main shop. I am in the process of setting up a new shop. I installed it everything seemed to be working but now it does not. I am not getting any errors. Just if I try to set at featured Product in Admin nothing happens. The little icon light stays red and the box that shows the items in the shop is just showing new Items as I upload the.

    When I am putting in all my details for new Item in does not matter if I make it a featured product or not does nothing. Any ideas what has happened. I have gone over files and nothing is glaring at me what could be wrong :(

    Comment by Cassie — July 22, 2008 @ 11:44 am


  56. Cassie – do the other buttons work – the ones which turn the STATUS of the product on and off?

    Comment by Gary — July 22, 2008 @ 3:02 pm


  57. Hi Gary Yes the Status buttons work.

    Comment by cassie — July 23, 2008 @ 12:51 am


  58. Hi again.
    Any ideas on what could be the problem?
    I have gone over all files and cannot see the problem at all :( Wondering if uninstalling and redoing it would make any difference. Tho have no idea about the SQL stuff if I need to do something there.

    Comment by cassie — July 27, 2008 @ 2:00 am


  59. If the status buttons work, then it's not an issue with your website or your website hosting. It can only be some code that you have missed somewhere…

    Comment by Gary — July 27, 2008 @ 8:40 am


  60. Thanks Gary.
    I ended up moving hosts and we had no end of problems with heaps of things on that host and once we moved everything over. My own fault for using the first host. Ended up just doing a whole new fresh install and one at a time adding mods.

    Works a charm on new install with all the mods added :) Thanks

    Comment by cassie — July 27, 2008 @ 11:06 am


  61. Good one :)

    Comment by Gary — July 27, 2008 @ 12:03 pm


  62. Hi there, I'm pretty new to this so it may be blindingly obvious but how can I hide the prices being displayed here? Thanks! D.

    Comment by Daleos — July 28, 2008 @ 3:18 pm


  63. Daleos – I think you would need to amend the module directly. Remove this:

    ' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])) . '

    Comment by Gary — July 28, 2008 @ 7:46 pm


  64. Thanks Gary, that's great!

    Comment by Daleos — July 30, 2008 @ 9:29 am


  65. Hi Gary

    I have installed the Featured Products module and don't get any errors on the website but I am only getting a single featured product in the left column info box.
    This happens on the main index page and all the categories pages.

    This set up is mentioned as an option in the install instructions :-

    'You also have the option of displaying just a side infobox that would display only one featured item.'

    There isn't any mention of how to turn on the full featured items product display (not just the side infobox).

    Is there a variable or file modification somewhere that I need to change to get the full display.

    Thanks for any help

    Billy

    Comment by Billy — September 15, 2008 @ 11:28 pm


  66. Billy – cannot help you as my featured product module does not have side infoboxes, so I assume you have installed a different one.

    Comment by Gary — September 17, 2008 @ 8:42 am


  67. Finally I managed to install this over my existing allready modded shop :) I have the sort product mod and both running OK, thx for this superb mod :)

    Comment by Tomee80 — September 24, 2008 @ 6:03 pm


  68. hello,

    i used the program "beyound compare" and i made all the changes to the files that you specified.i uploaded them on the server and when
    i go to administration panel to – catalog – categories i get this error :" Fatal error: Call to undefined function tep_hide_session_id() in /home/rmys0115/public_html/admin/categories.php on line 782
    " .Can you please help me?

    Comment by nicolas — October 8, 2008 @ 10:45 pm


  69. I managed to handle this error by modifying the code at – admin/includes/functions/html_output.php file
    I added these lnes:
    // Hide form elements
    function tep_hide_session_id() {
    $string = ";
    if (defined('SID') && tep_not_null(SID)) {
    $string = tep_draw_hidden_field(tep_session_name(), tep_session_id());
    }
    return $string;
    }

    above the the final ?> at the bottom of the file.(i found this fix on a forum not my idea.)

    Now "featured products" works fantastic.
    Thank you very much!

    Comment by nicolas — October 8, 2008 @ 11:17 pm


  70. Good work, Nicolas

    Comment by Gary — October 9, 2008 @ 4:11 pm


  71. Hi Gary

    Thanks for this feature, it was just what I was looking for! One problem I am having is that only 8 featured products are showing instead of 9. there is a "gap" in the bottom right corner. If you have any idea why I would really appreciate it!

    Cheers
    Matt

    Comment by Matthew — October 20, 2008 @ 11:30 pm


  72. Matt, assuming you have more than 8 products in your store! There are two options;

    1. You have only 8 products featured, hence 8 products should show if I recall correctly. I can't remember of the version I uploaded also includes other (not featured) items after the featured ones.
    or
    2. You have set a maximum of 8 products to show in the "new products" module. Check your admin area under configuration > max values

    Comment by Gary — October 21, 2008 @ 9:15 am


  73. Hi

    This is a fantastic contribution adding a simple mod without a lot of fuss.

    However, I have managed to install ok and apply the store template but can't make the new items display in 2 per row (2 column) layout. My other pages are ok, any way of amending this in the code ?

    Thanks again

    Steve

    Comment by Steve — January 24, 2009 @ 12:49 pm


  74. Steve – to cvhange the number of columns you need to amend the file driectly, it's not an admin setting.

    So open up the module and find;

    if ($col > 2) {

    change to

    if ($col > 1) {

    Cheers, Gary

    Comment by Gary — January 25, 2009 @ 6:04 pm


  75. Hi:

    I set up my website about a month or so ago (with a template) and I would like to install the featured product contribution to my website. Can you help me install the contribution? How much would it cost me?

    Thanks.

    Comment by Ravi Chandran — February 9, 2009 @ 9:28 pm


  76. Ravi – it really is a simple addition to a store, which I am sure you could manage. However, if you do want me to install, I can do that – email me on oscshops@gmail.com and we can go from there.

    Comment by Gary — February 10, 2009 @ 3:50 pm


  77. Thanks, Gary. You are correct. I was able to install it without much trouble and it sure is a great contribution. The only thing I did not do initiall was to run SQL query, but once I did that every thing worked out pretty well. (I am not picking on you but it was not in the list of things to do for this contribution!)

    Comment by Ravi Chandran — February 11, 2009 @ 10:39 pm


  78. Well the installation went fine. I'm able to toggle features on/off within the admin area,
    however when I look at my shop I see items from which I toggled the feature off.

    I only have 3 items in my shop so far (for testing purpose), does this feature only work
    when I got 9 or more items in my shop?

    Comment by Michael — April 28, 2009 @ 9:23 am


  79. Michael – it brings the featured products to the top of the list.

    Comment by Gary — April 28, 2009 @ 9:47 am


  80. Gary-
    I copied the files up and keep getting an error that the following function is not defined: echo tep_hide_session_id() . ";.
    When I comment it out admin\category.php works as before.
    Can you help?
    Also, what is the abrieviation "tep" used for?
    Thanks!
    Pete

    Comment by Pete Bonk — May 19, 2009 @ 2:20 pm


  81. Pete – you probably be safe to remove that piece of code.

    "tep" stands for The Exchange Project, which is what osCommerce was known as before it became osCommerce.

    Comment by Gary — May 20, 2009 @ 2:21 pm


  82. Hello Burt,

    I installed this featured products on a new RC2a site. It took a little bit of doing since I have SEO header tags and also Products Short Description. I feel like I merged everything correctly, but when I finished the admin side works fine. On the catalog side I got this error
    Call to a member function add_current_page() on a non-object in application_top.php
    Since app top is not edited, and you designed the mod, I was hoping you might have a starting place for me to look.

    Thanks,
    Tim

    Comment by Tim — August 6, 2009 @ 5:57 pm


  83. I got it Burt. Simple mistake in the new products module. I noticed the featured products are static. Only the most recently added products show up. If I add more than my page will hold, they do not rotate. Is this something that can be changed?

    Tim

    Comment by Tim — August 7, 2009 @ 12:27 am


  84. Hi Tim, have a look for the "order by" part of the SQL code in the module, and change it to order by RAND()
    That should do it. Cheers Gary

    Comment by Gary — August 10, 2009 @ 9:01 am


  85. Hello,
    Thank you for the great add on. My site is modified with seo header tags, html rewrite, easy populate, osc thumbs and design changes.
    It works great but rarely i get an sql error something about line 18 when an image is not present. Is there a common problem if there is not image and the product is in the featured area?
    Let me know.

    Comment by classic recreations — December 9, 2009 @ 4:02 pm


  86. I've not been made aware of anyone else having that same problem, so my guess would be something else causing it.

    Cheers, Gary

    Comment by Gary — December 14, 2009 @ 1:06 pm


  87. Hi,

    I installed the add on (used Beyond Compare) and it works fine in the admin area and on the main page but the checkout shipping page is now blank… Could you please help, in which file(s) should I start to look for errors. I run everything through Beyond Compare again and the files seems to be updated as in the add on package.

    Thanks!

    Comment by Malin — May 15, 2010 @ 7:14 am


  88. Hi Malin

    As far as I recall, the changes shouldn;t affect that file, so you might need to revert to your saved backup, and try again.

    Comment by Gary — May 17, 2010 @ 1:02 pm


Leave a comment

RSS feed for comments on this post · TrackBack URL

Hot 100 osCommerce Shops

View the osCommerce HOT 100These are the best looking, most exceptional osCommerce Stores as voted for by you.

New to osCommerce - get inspiration from these beautiful shops. Reckon your site has what it takes to become a member of the HOT 100? Submit it!