Traffic Lights for showing Stock in osCommerce
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:
-
<br />' . clubosc_products_stock((int)$products_new['products_id']) . '
Right after:
-
' . $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?



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
Hi make sure you are passing thru the correct ID for the product.
Comment by Gary — December 18, 2009 @ 11:03 am
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
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
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
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