About Club osCommerce

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

StumbleUpon It! DIGG It!

Traffic Lights for showing Stock in osCommerce

Written By Gary on Mar 24 2009 · Comments (6)

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!


The other day a client approached me about a feature which he had seen on a store (not an osCommerce store). To cut a long story short, it showed available levels of stock in a "traffic light" system;

More than 10 on hand = green
Between 2 and 9 = orange
Less than 2 = red

With a bit of thought, I adapted a previous idea of mine, blogged here. And ended up with a good way of showing what's in stock, what's limited etc.

In the Categories structure (index.php)

In the Product page (product_info.php)

In the New Product listing (prodcuts_new.php)

Let's say I want to show traffic lights in the "New Products for Month" box

I open up /includes/modules/new_products.php and add this:

PHP:
  1. <br />' . clubosc_products_stock((int)$products_new['products_id']) . '

Right after:

PHP:
  1. ' . $new_products['products_name'] . '</a>

So now instead of looking like this:

It looks like this:

Function this, function that

Because I used a function to "power" this, it is really easy to change - so let's say the shop owner wanted to change the word "Available" (green traffic light) to "We got loads, buy now!", he can just go to 1 file (includes/languages/english.php), change it and this will be reflected on ALL the pages that show the "traffic lights" - meaning the shop owner doesn't have to change lots of files. Good, eh?

6 Comments

  1. In product_info it's ok, but in new_products, I only view the red light…

    Comment by Jose — December 17, 2009 @ 11:28 pm


  2. Hi make sure you are passing thru the correct ID for the product.

    Comment by Gary — December 18, 2009 @ 11:03 am


  3. Sorry, I'm novice in this…
    Maybe the problem is that I need a new function for new_products, changing the switch(tep_get_products_stock($pID)) ??????????

    Thanks

    Comment by Jose — December 18, 2009 @ 11:57 am


  4. Hi new function is not needed – you need to pass the correct ID through to the function for processing.

    Comment by Gary — December 18, 2009 @ 12:08 pm


  5. I don't understand why in product_info it runs, but in new_produts, and product_listing, it doesn' runs.

    Comment by Jose — December 18, 2009 @ 12:58 pm


  6. Because you are not passing the correct product ID. If you want me to help you further, one on one, email me and I can quote you to install it.

    Comment by Gary — December 18, 2009 @ 12:59 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!