Page 1 of 1

How to show number of items in stock on product page?

Posted: Tue Jan 05, 2016 5:59 pm
by fokz8
Hey there.

When i go to my product page for specified item, i get desplayed "In stock" or "Out of stock". How is it possible, to display the number of items in stock, so that display would be like:

Stock: 50

Thanks :)

Re: How to show number of items in stock on product page?

Posted: Tue Jan 05, 2016 6:57 pm
by jimmyphong
Edit product controller

Open file

Code: Select all

catalog/controller/product/product.php
find

Code: Select all

if ($product_info['quantity'] <= 0) {
add before

Code: Select all

$data['number_stock'] = $product_info['quantity'] 
open file

Code: Select all

catalog\view\theme\your theme\template\product\product.tpl
find

Code: Select all

<?php echo $stock; ?>
replace

Code: Select all

<?php echo $number_stock;?>

Re: How to show number of items in stock on product page?

Posted: Tue Jan 05, 2016 9:46 pm
by fokz8
jimmyphong wrote:Edit product controller

Open file

Code: Select all

catalog/controller/product/product.php
find

Code: Select all

if ($product_info['quantity'] <= 0) {
add before

Code: Select all

$data['number_stock'] = $product_info['quantity'] 
open file

Code: Select all

catalog\view\theme\your theme\template\product\product.tpl
find

Code: Select all

<?php echo $stock; ?>
replace

Code: Select all

<?php echo $number_stock;?>
Thank you, it works perfect!

Re: How to show number of items in stock on product page?

Posted: Wed Jan 06, 2016 5:58 am
by IP_CAM
@jimmyphong, you just forgot to add the ';' ;)
$data['number_stock'] = $product_info['quantity']
to make it look like;
$data['number_stock'] = $product_info['quantity'];

I created a free little VqMod for this, to match OpenCart v.1.5.6.x - v.2.x Versions
---
OpenCart v.2.x VqMod, tested here:
http://www.jti.li/shop/index.php?route= ... duct_id=29

OpenCart v.1.5.6.5_rc VqMod, tested here:
http://www.openshop.li/cart/index.php?r ... ct_id=4936

Display Stock on Product Page VqMod Extension Download Link:
http://www.opencart.com/index.php?route ... n_id=25260

Good Luck ;)
Ernie