Traffic Lights for showing Stock in osCommerce

By | March 24, 2009

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]
‘ . clubosc_products_stock((int)$products_new[‘products_id’]) . ‘[/php]

Right after:

[php]’ . $new_products[‘products_name’] . ‘[/php]

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 thoughts on “Traffic Lights for showing Stock in osCommerce

  1. Gary Post author

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

  2. Jose

    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

  3. Gary Post author

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

  4. Jose

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

  5. Gary Post author

    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.

Leave a Reply

Your email address will not be published. Required fields are marked *