Post by jpress69 » Fri Nov 28, 2014 7:07 am

I was wondering if its possible to make a little indicator light, green, yellow or red to indicate stock status in the cart?
0= red out of stock
1-10 yellow low stock
11+ green in stock

See the picture that I did in photoshop

Attachments

Screen Shot 2014-11-27 at 3.03.31 PM.png

Screen Shot 2014-11-27 at 3.03.31 PM.png (102.06 KiB) Viewed 2908 times


User avatar
New member

Posts

Joined
Mon Nov 03, 2014 4:52 pm
Location - Los Angeles

Post by pprmkr » Fri Nov 28, 2014 3:33 pm

Edit catalog/controller/product/product.php
Before:

Code: Select all

if ($product_info['quantity'] <= 0) {
Add:

Code: Select all

			if ($product_info['quantity'] > 10) {
				$data['stock_indicator'] = 'green';
			} else {
				$data['stock_indicator'] = 'yellow';	
			}
After:

Code: Select all

if ($product_info['quantity'] <= 0) {
Add:

Code: Select all

				$data['stock_indicator'] = 'red';	
Edit catalog/view/theme/default/template/product/product.tpl
Find and replace:

Code: Select all

            <li><?php echo $text_stock; ?> <?php echo $stock; ?></li>
With:

Code: Select all

            <li><?php echo $text_stock; ?> <?php echo $stock; ?> <img src="image/stock_status_<?php echo $stock_indicator; ?>.png" alt="stock status" /></li>
Upload images to /image:
- stock_status_red.png
- stock_status_yellow.png
- stock_status_green.png

User avatar
Active Member

Posts

Joined
Sat Jan 08, 2011 11:05 pm
Location - Netherlands

Post by jpress69 » Fri Nov 28, 2014 3:38 pm

Thanks for that code!! How will the system know the stock qtys though for the different colors?

User avatar
New member

Posts

Joined
Mon Nov 03, 2014 4:52 pm
Location - Los Angeles

Post by pprmkr » Fri Nov 28, 2014 4:03 pm

It's in the code:

if more than 10 -> green
else -> yellow
if less than or equal to 0 -> red

User avatar
Active Member

Posts

Joined
Sat Jan 08, 2011 11:05 pm
Location - Netherlands

Post by jpress69 » Fri Nov 28, 2014 4:09 pm

Ohm i got it!! Thanks so much.. Check it out socalhobbies.com I'm working on it as i type this!

User avatar
New member

Posts

Joined
Mon Nov 03, 2014 4:52 pm
Location - Los Angeles

Post by marjanl » Fri Feb 13, 2015 5:18 pm

Does this apply also to for 2.0.1.1? Because I'm try, but not working.

Best regards,

Marjan

Newbie

Posts

Joined
Fri Feb 13, 2015 5:15 pm

Post by pprmkr » Sat Feb 14, 2015 1:51 pm

Yes, it does !

Did you create the images?
Code inserted in the right place?

User avatar
Active Member

Posts

Joined
Sat Jan 08, 2011 11:05 pm
Location - Netherlands
Who is online

Users browsing this forum: No registered users and 7 guests