Latest Articles
So far this was never an issue, there were problems with uploading modules via the installer because of the ftp connection but you could allways install ocmods without any issue. However, some .. Read More
People had this issue so many times I thought I would write a bit about it. The  types of issues with opencart's 2.x modification system that I identified so far are: 1. Old Vqmod .. Read More
This small tutorial will show you how to manually add custom links to the default top menu in opencart. If you dont want to go trough all the hustle and would like to be able to completly customize.. Read More
To enable seo urls in opencart navigate in admin to system > settings , edit the store and on the server tab of the store settings you will find "Use SEO urls", set it to yes. So far e.. Read More
All Articles

Display stock in opencart product listing

If you want to display the stock or stock status(like on product page) on the product linsting (category, search) here is how you do it.

Edit the file catalog/controller/product/category.php
Find the code:

if ($this->config->get('config_review_status')) {
$rating = (int)$result['rating'];
} else {
$rating = false;
}

below it add:

if ($result['quantity'] <= 0) {
$rstock = $result['stock_status'];
} elseif ($this->config->get('config_stock_display')) {
$rstock = "Stoc: " . $result['quantity'];
} else {
$rstock = "In stoc";
}

Then, after the code:


'thumb' => $image,

add:

'stoc' => $rstock,

Edit the file catalog/view/theme/yourtheme/template/product/category.tpl

after:

<div class="cart">

add

<?php echo $product['stoc']; ?><br />

And now the stock will appear for products in category page. You can do the same for search (the files would be search.php and search.tpl - in the same folders as the category)

Posted by Flo