Display stock quantity on product options
3 posts
• Page 1 of 1
Display stock quantity on product options
I've trawled through loads of different threads reading about all sorts of different stock control requests and different things. I was recently looking to display the stock available on each of my product options, figured out a fairly simple way and thought I would share it on here - as I've used loads of things from the rest of the community.
Please note that is by no means the best method of how to do this, but it works for me.
In controller/product/product.php
On around line 246 find
and add below
In view/theme/themename/template/product/product.tpl
(I use Radio boxes to select my option, but this will work with any method)
On around line 94 find
On the last line, you want to make it say the following
This will then display the quantity that item has in stock next to the option. You can then set it for example to only display when subtrack stock is set to yes, or add a div and give it its own style etc. There are plenty of things that can be done with this.
(What I've done for example is set it so show in Red when the stock is less than 5, and Green when the stock is more than 5)
I'm sorry my 'fix' isn't as slick as others offered, but hopefully this helps someone out at some point.
Please note that is by no means the best method of how to do this, but it works for me.
In controller/product/product.php
On around line 246 find
- Code: Select all
'name' => $option_value['name'],
and add below
- Code: Select all
'quantity' => $option_value['quantity'],
In view/theme/themename/template/product/product.tpl
(I use Radio boxes to select my option, but this will work with any method)
On around line 94 find
- Code: Select all
<b><?php echo $option['name']; ?>:</b><br />
<?php foreach ($option['option_value'] as $option_value) { ?>
<input type="radio" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option_value['product_option_value_id']; ?>" id="option-value-<?php echo $option_value['product_option_value_id']; ?>" />
<label for="option-value-<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
<?php if ($option_value['price']) { ?>
(<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
<?php } ?>
</label>
On the last line, you want to make it say the following
- Code: Select all
<?php echo $option_value['quantity']; ?></label>
This will then display the quantity that item has in stock next to the option. You can then set it for example to only display when subtrack stock is set to yes, or add a div and give it its own style etc. There are plenty of things that can be done with this.
(What I've done for example is set it so show in Red when the stock is less than 5, and Green when the stock is more than 5)
I'm sorry my 'fix' isn't as slick as others offered, but hopefully this helps someone out at some point.
- romerz
- Posts: 19
- Joined: Wed Feb 16, 2011 3:56 pm
Re: Display stock quantity on product options
Thanks for sharing. It is really useful.
-

rishi - Posts: 33
- Joined: Sun May 16, 2010 9:34 pm
Re: Display stock quantity on product options
quicks a treat but only in radio mode, any idea how to get it to work in image mode, as i need to display colour pictures for the items on the store
thanks
plex
thanks
plex
- plexone
- Posts: 2
- Joined: Thu Nov 01, 2012 12:16 am
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: UncleAndy and 12 guests













