Page 2 of 2

Re: Remove (disable) out of stock items

Posted: Tue Nov 29, 2011 4:51 am
by salehjoon
Instead of change core files, I've made changes to my template files, removing the button when stock = 0. For example:

/opencart/catalog/view/theme/mytheme/template/product/product.tpl (~line 180):

Code: Select all
<?php if ($product_info['quantity']) { ?>
<div class="cart">
<div><?php echo $text_qty; ?>
<input type="text" name="quantity" size="2" value="<?php echo $minimum; ?>" />
<input type="hidden" name="product_id" size="2" value="<?php echo $product_id; ?>" />&nbsp;<a id="button-cart" class="button"><span><?php echo $button_cart; ?></span></a>
</div>
<?php if ($minimum > 1) { ?>
<div class="minimum"><?php echo $text_minimum; ?></div>
<?php } ?>
</div>
<?php } ?>


I've added the first if statement. That's it.
This method doesn't work.

Re: Remove (disable) out of stock items

Posted: Tue Jan 03, 2012 10:34 pm
by DOzric
I am researching a shop for someone selling antiques. This is going to be 1 item each and wondered if this is an option yet without a hack or on the road map. I don't like changing code and worry about updates messing with this setting.

There must be a good percentage of people selling single items and could use this option.

Thank you

Re: Remove (disable) out of stock items

Posted: Tue Jan 03, 2012 10:47 pm
by fido-x

Re: Remove (disable) out of stock items

Posted: Fri Jan 20, 2012 12:53 am
by slik
+1 who need such option ) mb if there will be a lot of ppl needed it developers will add it?

Re: Remove (disable) out of stock items

Posted: Thu Feb 16, 2012 9:41 am
by Chris!
I would also love to see that products are not being listed when they are not in stock.
Setting them inactive manually would be a pain-staking process for those who have big stores with thousands of products listed in them.

Re: Remove (disable) out of stock items

Posted: Wed Mar 21, 2012 8:22 pm
by Mike Guenther
I agree, I am shocked this isn't an option. It is a pain to manually have to do this, but if you are not on top of it you could easily oversell product that you don't have in stock. Then you would have to offer refunds. yuck.

Re: Remove (disable) out of stock items

Posted: Thu Aug 23, 2012 11:25 pm
by esponi
We have developed something like that in our store:
Products with stock = 0, you will be able to:
- Hide product
or
- Hide "add to cart" button
or
- Change "add to cart" button behavior, to redirect to "Contact to get a quote" or a custom text.

We plan to convert this into an extension.
Any more ideas to add?

Re: Remove (disable) out of stock items

Posted: Tue Sep 04, 2012 12:53 am
by brain
Thanks for the mod Qphoria. Works great except for one problem that I am seeing. It doesn't hide the product on the category page. I don't think there were categories yet in the version this was intended for, however it does work for every page but that one. Not sure what code I would need to edit to ensure it is hidden on this page as well. Any ideas?

For esponi: Any news on this mod you are referring?

Re: Remove (disable) out of stock items

Posted: Mon Sep 10, 2012 10:32 pm
by esponi
Yes, we will port to an extension in a few days:
Included features in each product form:
If stock = 0:
[ x ] Hide this product.
[ x ] Hide only "add to cart" button.
[ x ] Change text "add to cart" to new text: ..........................
[ x ] Change "add to cart" button behavior, redirect to ................................?product_id={this}

What do you think.

Re: Remove (disable) out of stock items

Posted: Thu Sep 27, 2012 3:39 am
by Minimera
@Esponi: Sounds really good. Where can I find the extention?

/Linda

Re: Remove (disable) out of stock items

Posted: Tue Oct 16, 2012 6:08 pm
by esponi
Minimera: Release is stopped due low interest.

Re: Remove (disable) out of stock items

Posted: Wed Nov 27, 2013 1:48 am
by mr.bacan
Qphoria wrote:1. Edit: catalog/model/catalog/product.php
2. All places you find:

Code: Select all

p.status = '1'
3. Replace with:

Code: Select all

p.status = '1' AND p.quantity > '0'
Thanks a lot. This solution worked like a charm on Version 1.5.5.1.

Re: Remove (disable) out of stock items

Posted: Fri Jan 29, 2016 7:59 pm
by stelian99
Hello guys,

I know that it's an old thread. I run a shop based on OC 1.5.1.3. I've tried few extensions for hide products that are out of stock, but not one keep the product url valid. Any tips?

Thank you!

Re: Remove (disable) out of stock items

Posted: Tue Sep 06, 2016 4:31 am
by esponi
What do you mean With valid url?

Re: Remove (disable) out of stock items

Posted: Mon Jan 22, 2018 3:48 am
by opencart-solutions
Hello
InStock Only for all page when show products: category, special, search, manufacturer
https://www.opencart.com/index.php?rout ... n_id=33009

Re: Remove (disable) out of stock items

Posted: Thu May 02, 2019 11:18 pm
by masterross
It's not good for SEO to remove products.

Go to /opencart/catalog/view/theme/mytheme/template/product/product.tpl
and change:

Code: Select all

<button type="button" id="button-cart" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-primary btn-lg btn-block"><?php echo $button_cart; ?></button>
To:

Code: Select all

        <?php if ($stockqty) { ?>
        <button type="button" id="button-cart" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-primary btn-lg btn-block"><?php echo $button_cart; ?></button>
       <?php } else {?>
       <span class="btn btn-primary btn-lg btn-block">Out of Stock</span>
        <?php } ?>

Re: Remove (disable) out of stock items

Posted: Thu May 02, 2019 11:21 pm
by straightlight
<?php if ($stockqty) { ?>
I wonder where this variable is coming from . . .