Featured Products in osCommerce

By | April 2, 2008

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.

88 thoughts on “Featured Products in osCommerce

  1. Gary Post author

    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.

  2. Gaston

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

  3. Gary Post author

    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

  4. Adam

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

  5. Gary Post author

    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?

  6. Adam

    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

  7. Gary Post author

    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.

  8. Gary Post author

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

  9. Gary Post author

    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!

  10. Pingback: Club osCommerce » Random Products on Front Page

  11. Glosticks

    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

  12. Gary Post author

    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

  13. mike

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

  14. Gary Post author

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

  15. mike

    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.

  16. Gary Post author

    Mike – strange that many have installed without problems. Very strange ๐Ÿ˜‰

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

  17. mike

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

  18. Sam

    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.

  19. Gary Post author

    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.

  20. Sam

    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.

  21. Gary Post author

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

  22. Sam

    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? ๐Ÿ™‚

  23. jgeoff

    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…?

  24. Gary Post author

    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.

  25. jgeoff

    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?

  26. Gary Post author

    Works OK on mine. Must be “just you” ๐Ÿ˜‰

  27. jgeoff

    LOL The radio button says “No”, but after submitting it’s still featured… for me. ๐Ÿ˜‰

  28. Gary Post author

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

  29. jgeoff

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

  30. jgeoff

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

  31. mike

    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.

  32. Gary Post author

    There is no bug that causes this – it’s user error ๐Ÿ˜‰

  33. Chris

    does your version show products from subcategories?

  34. Gary Post author

    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

  35. Emma

    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?

  36. Gary Post author

    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.

  37. Laurence

    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!

  38. Laurence

    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!

  39. Gary Post author

    Laurence – not too difficult really is it ๐Ÿ˜‰

  40. aoife

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

    Thanks!

  41. Gary Post author

    Aoife – that’s right ๐Ÿ™‚

  42. Charles

    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?

  43. Gary Post author

    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’

  44. Laurence

    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

  45. cassie

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

  46. Gary Post author

    Deb – good work!

    Cassie – in teh language file for index.php

  47. cassie

    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 ๐Ÿ™‚

  48. Cassie

    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 ๐Ÿ™

  49. Gary Post author

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

  50. cassie

    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.

  51. Gary Post author

    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…

  52. cassie

    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

  53. Daleos

    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.

  54. Gary Post author

    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’])) . ‘

  55. Billy

    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

  56. Gary Post author

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

  57. Tomee80

    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 ๐Ÿ™‚

  58. nicolas

    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?

  59. nicolas

    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!

  60. Matthew

    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

  61. Gary Post author

    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

  62. Steve

    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

  63. Gary Post author

    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

  64. Ravi Chandran

    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.

  65. Gary Post author

    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.

  66. Ravi Chandran

    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!)

  67. Michael

    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?

  68. Gary Post author

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

  69. Pete Bonk

    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

  70. Gary Post author

    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.

  71. Tim

    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

  72. Tim

    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

  73. Gary Post author

    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

  74. classic recreations

    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.

  75. Gary Post author

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

    Cheers, Gary

  76. Malin

    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!

  77. Gary Post author

    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.

Leave a Reply

Your email address will not be published.