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