Post by megahuman » Wed Oct 31, 2012 5:11 pm

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

Web Design and Development at 7 Design


Active Member

Posts

Joined
Tue Dec 14, 2010 4:57 pm

Post by anung » Thu Nov 01, 2012 2:02 am

First.
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>
after this code

Code: Select all

<?php if ($product['tax']) { ?>
        <br />
        <span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
        <?php } ?>
Second.
open category.php in catalog/controller/product and put this code

Code: Select all

 $this->data['text_stock'] = $this->language->get('text_stock');
After this code

Code: Select all

$this->data['text_limit'] = $this->language->get('text_limit');
And put this code

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');
            }
Before this code

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'])
);
Third.
open category.php in catalog/language/english/product then put this code

Code: Select all

$_['text_stock']        = 'Availability:';
$_['text_instock']      = 'In Stock';
After this code

Code: Select all

$_['text_limit']        = 'Show:';

User avatar
Active Member

Posts

Joined
Fri Mar 30, 2012 10:32 am
Location - Indonesia

Post by megahuman » Thu Nov 01, 2012 4:59 am

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!

Web Design and Development at 7 Design


Active Member

Posts

Joined
Tue Dec 14, 2010 4:57 pm

Post by humpadilly » Wed Apr 10, 2013 10:37 pm

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?

Newbie

Posts

Joined
Wed Mar 06, 2013 3:06 pm

Post by humpadilly » Sat Apr 13, 2013 10:30 pm

anung wrote:First.
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>
after this code

Code: Select all

<?php if ($product['tax']) { ?>
<br />
<span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
<?php } ?>
Second.
open category.php in catalog/controller/product and put this code

Code: Select all

 $this->data['text_stock'] = $this->language->get('text_stock');
After this code

Code: Select all

$this->data['text_limit'] = $this->language->get('text_limit');
And put this code

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');
}
Before this code

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'])
);
Third.
open category.php in catalog/language/english/product then put this code

Code: Select all

$_['text_stock'] = 'Availability:';
$_['text_instock'] = 'In Stock';
After this code

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,
add

Code: Select all

'stock'       => $this->data['stock'],
in file yourtheme/template/product/category.tpl

instead of

Code: Select all

<div><span style="color:#38B0E3;"><?php echo $text_stock; ?></span><?php echo $stock; ?></div>
use

Code: Select all

<div><span style="color:#38B0E3;"><?<?php echo $text_stock; ?></span><?php echo $product['stock']; ?></div>
This will then show the stock status for every product in the category correctly

Newbie

Posts

Joined
Wed Mar 06, 2013 3:06 pm

Post by megahuman » Sun Jun 09, 2013 8:24 pm

Just tested this out, didn't even realise their was a reply. This fix works a treat! Thank you!

Web Design and Development at 7 Design


Active Member

Posts

Joined
Tue Dec 14, 2010 4:57 pm

Post by jidol » Thu Jul 04, 2013 7:58 pm

Hi, how to modify this set od scripts to work on manufacturer page?? I tried this and it doesnt work ...thank for answer.

Newbie

Posts

Joined
Thu Jul 16, 2009 8:11 pm

Post by humpadilly » Sun Jul 14, 2013 8:50 pm

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

Newbie

Posts

Joined
Wed Mar 06, 2013 3:06 pm

Post by v-v » Tue Dec 31, 2013 11:21 pm

Hi, any idea how to adapt it for special?
Thank you.

v-v
Active Member

Posts

Joined
Wed Jun 16, 2010 10:09 pm

Post by dazoosh » Sat Jan 11, 2014 5:26 pm

v-v wrote:Hi, any idea how to adapt it for special?
Thank you.
It's exactly the same process as adding to category (as above).

New member

Posts

Joined
Mon Dec 10, 2012 6:10 pm

Post by jason2010 » Thu Mar 06, 2014 7:45 am

This seems to work great, but is there a way to just show "In Stock". When I make these mods it shows the actual stock qty, but only want to show "In Stock"

New member

Posts

Joined
Thu Apr 04, 2013 6:27 am

Post by jason2010 » Thu Mar 06, 2014 7:50 am

Also is there a way of showing the Availability on the Search page when doing a search?

New member

Posts

Joined
Thu Apr 04, 2013 6:27 am

Post by JIMSLITA » Thu Mar 06, 2014 4:30 pm

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.


User avatar
New member

Posts

Joined
Fri Feb 08, 2013 3:49 pm

Post by JIMSLITA » Thu Mar 06, 2014 4:33 pm

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.


User avatar
New member

Posts

Joined
Fri Feb 08, 2013 3:49 pm

Post by jason2010 » Sun Mar 09, 2014 2:58 am

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

New member

Posts

Joined
Thu Apr 04, 2013 6:27 am

Post by hibar3 » Tue Mar 18, 2014 9:47 pm

Just tried....Works Brilliantly :) thanks a ton.
Can anyone help me out in removing "Availability" text.I only want "out of stock".Also how do we change the color of the text "Out of stock".

Newbie

Posts

Joined
Tue Mar 18, 2014 9:00 pm

Post by jason2010 » Fri Jul 18, 2014 3:12 am

is there a way of adding this code somewhere so that the availablity shows on the search page as well?

New member

Posts

Joined
Thu Apr 04, 2013 6:27 am

Post by gofie » Sat Jul 19, 2014 6:07 am

Unfortunately does not work for me, only gives figures. Does anyone know how that can

New member

Posts

Joined
Thu Sep 12, 2013 3:37 am

Post by jason2010 » Sat Aug 02, 2014 7:20 am

anyone know of a way to show this on the search page as well?

New member

Posts

Joined
Thu Apr 04, 2013 6:27 am

Post by 2Gates » Thu Mar 24, 2016 6:47 pm

jason2010 wrote:anyone know of a way to show this on the search page as well?
I want to show it on the search page too Jason. Were you able to do it?

I posted my Wealthy Affiliate review just now!


Newbie

Posts

Joined
Wed Mar 23, 2016 6:44 pm
Who is online

Users browsing this forum: Google [Bot] and 35 guests