Hi all,
Using Opencart 1.5.4
I'm sure somebody would have asked this before but I couldn't find anything relevant in a search, I may just be tired though but is there anyway to show "In Stock, Out of Stock" on the categories page for each individual product?
I'm sure its easy to do, I'm just not very good with PHP.
Thanks Guys
Using Opencart 1.5.4
I'm sure somebody would have asked this before but I couldn't find anything relevant in a search, I may just be tired though but is there anyway to show "In Stock, Out of Stock" on the categories page for each individual product?
I'm sure its easy to do, I'm just not very good with PHP.
Thanks Guys
First.
open category.tpl in catalog/view/theme/yourtheme/template/product then put this code
after this code
Second.
open category.php in catalog/controller/product and put this code
After this code
And put this code
Before this code
Third.
open category.php in catalog/language/english/product then put this code
After this code
open category.tpl in catalog/view/theme/yourtheme/template/product then put this code
Code: Select all
<div><span style="color:#38B0E3;"><?php echo $text_stock; ?></span><?php echo $stock; ?></div>
Code: Select all
<?php if ($product['tax']) { ?>
<br />
<span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
<?php } ?>
open category.php in catalog/controller/product and put this code
Code: Select all
$this->data['text_stock'] = $this->language->get('text_stock');
Code: Select all
$this->data['text_limit'] = $this->language->get('text_limit');
Code: Select all
if ($result['quantity'] <= 0) {
$this->data['stock'] = $result['stock_status'];
} elseif ($this->config->get('config_stock_display')) {
$this->data['stock'] = $result['quantity'];
} else {
$this->data['stock'] = $this->language->get('text_instock');
}
Code: Select all
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'rating' => $result['rating'],
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'])
);
open category.php in catalog/language/english/product then put this code
Code: Select all
$_['text_stock'] = 'Availability:';
$_['text_instock'] = 'In Stock';
Code: Select all
$_['text_limit'] = 'Show:';
Thanks for that Anung!
Is it possible to make it show the words 'out of stock' also when the product is out of stock?
Thanks
EDIT -----
This makes it ONLY say In Stock, as in, even if the product has no stock, it still says its 'in stock'.
Can you help? Thanks!
Is it possible to make it show the words 'out of stock' also when the product is out of stock?
Thanks
EDIT -----
This makes it ONLY say In Stock, as in, even if the product has no stock, it still says its 'in stock'.
Can you help? Thanks!
i am running 1.5.4.1 and this kind of works...
I get the same stock amount for every item on that page, it looks like it takes the stock from the last item and applies it to every item in the list.
any ideas?
I get the same stock amount for every item on that page, it looks like it takes the stock from the last item and applies it to every item in the list.
any ideas?
anung wrote:First.
open category.tpl in catalog/view/theme/yourtheme/template/product then put this codeafter this codeCode: Select all
<div><span style="color:#38B0E3;"><?php echo $text_stock; ?></span><?php echo $stock; ?></div>
Second.Code: Select all
<?php if ($product['tax']) { ?> <br /> <span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span> <?php } ?>
open category.php in catalog/controller/product and put this codeAfter this codeCode: Select all
$this->data['text_stock'] = $this->language->get('text_stock');
And put this codeCode: Select all
$this->data['text_limit'] = $this->language->get('text_limit');
Before this codeCode: Select all
if ($result['quantity'] <= 0) { $this->data['stock'] = $result['stock_status']; } elseif ($this->config->get('config_stock_display')) { $this->data['stock'] = $result['quantity']; } else { $this->data['stock'] = $this->language->get('text_instock'); }
Third.Code: Select all
$this->data['products'][] = array( 'product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..', 'price' => $price, 'special' => $special, 'tax' => $tax, 'rating' => $result['rating'], 'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']), 'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id']) );
open category.php in catalog/language/english/product then put this codeAfter this codeCode: Select all
$_['text_stock'] = 'Availability:'; $_['text_instock'] = 'In Stock';
Code: Select all
$_['text_limit'] = 'Show:';
so there are 2 missing bits in the instructions above...
in /catalog/controller/product/category.php
After
Code: Select all
'special' => $special,
Code: Select all
'stock' => $this->data['stock'],
instead of
Code: Select all
<div><span style="color:#38B0E3;"><?php echo $text_stock; ?></span><?php echo $stock; ?></div>
Code: Select all
<div><span style="color:#38B0E3;"><?<?php echo $text_stock; ?></span><?php echo $product['stock']; ?></div>
Just tested this out, didn't even realise their was a reply. This fix works a treat! Thank you!
Do the same thing as mentioned above but instead in files... I just tried it and it worked fine for me.
catalog\language\english\product\manufacturer.php
catalog\controller\product\manufacturer.php
catalog\view\theme\"your theme here"\template\product\manufacturer_info.tpl
catalog\language\english\product\manufacturer.php
catalog\controller\product\manufacturer.php
catalog\view\theme\"your theme here"\template\product\manufacturer_info.tpl
It will be slightly more complicated as 'In Stock' is in the product.php (language file) but 'Out of Stock' is a Stock Status - try looking at OC2PS excellent free extension - it may do the job for you just as well http://www.opencart.com/index.php?route ... on_id=7095 or alternatively give you a good idea of how to achieve what you want by following the vqmod as a guide.
OC v 1.5.4 with alot of tweaks,exts & mods.
Thinking about it - the simplest approach would be to use OC2PS extension and rename your add to cart button to IN STOCK in admin/language/english/english.php that way you would have an IN STOCK button and OUT OF STOCK text depending on availability.
OC v 1.5.4 with alot of tweaks,exts & mods.
What I'm trying to do is exactly like this extention except this extention doesn't work for 1.5.4.1
http://www.opencart.com/index.php?route ... ity&page=1
http://www.opencart.com/index.php?route ... ity&page=1
I want to show it on the search page too Jason. Were you able to do it?jason2010 wrote:anyone know of a way to show this on the search page as well?
I posted my Wealthy Affiliate review just now!
Who is online
Users browsing this forum: Bing [Bot] and 397 guests