Page 1 of 2

Remove (disable) out of stock items

Posted: Thu Oct 15, 2009 12:46 pm
by sgfx
Most of the items in my store will be in stock only once. so when they are sold out, most likely they will not be restocked.
How would someone change a items status in the db to "disable", instead of simply listed out of stock in the front end?

Once a item is gone I have no reason for it to still show up in the store.

I don't what to delete the item from the db yet, I would rather do that in the admin once I know for sure it was really sold out or not going to be restocked.

It might be good if this could be made an option that could be triggered off of the "Out Of Stock Status:" in the admin area so if you chose let say "disable item" instead of "More Coming Soon" or "Out of stock" then it would automatically disable the item. - I am sure there are others who could use something like this.

Re: Remove (disable) out of stock items

Posted: Fri Oct 16, 2009 2:33 am
by Jan R
Oh my.. That is just what i needed. Have you found a way to do this yet?
I have been using Open Cart for a friends store but i can see that Would help her us so much. :D :D

Re: Remove (disable) out of stock items

Posted: Fri Oct 16, 2009 5:17 am
by Qphoria
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'

Re: Remove (disable) out of stock items

Posted: Fri Oct 16, 2009 6:13 am
by sgfx
Works like a charm... I love simple solutions.!

I also had to make that same change to your Controller/product/all.php so that it works with your free "Show All Products" plugin.

Thanks Qphoria .

Perhaps that will be an standard option in an upcoming upgrade.

Re: Remove (disable) out of stock items

Posted: Fri Oct 16, 2009 9:19 am
by Qphoria
why does it need to be? The change was so simple and you are done.

Re: Remove (disable) out of stock items

Posted: Fri Oct 16, 2009 9:43 am
by sgfx
Oh yes it was simple .. I just think that it would be a good option (because it is so easy to do) to have for others and something that would not have to redone after each update (assuming the file changes in an update)
I don't know perhaps no one else needs such a thing.
Thanks again.

Re: Remove (disable) out of stock items

Posted: Sat Oct 17, 2009 1:49 am
by Jan R
Jan here
What a simple fix, (thanks Qphoria) Sally said this is going to help us out a lot. :)

I agree with sgfx. If it was settable in the administration area in the future, that would be cool. 8)
I like the ideal of adding it to the pull down were we select 'out of stock' or 'more coming soon'

Good job guys. -=:@:=-

Re: Remove (disable) out of stock items

Posted: Mon Nov 08, 2010 10:07 pm
by mat-ko
both cases make sence to me, it may or may not be wanted to display products of quantity=0. Me I need to display all enabled products, even if they aren't actually on stock. A setting would be a great solution I think :)

Re: Remove (disable) out of stock items

Posted: Mon Nov 29, 2010 5:55 pm
by nakz
Thanks Qphoria!
How do I disable this for "Option" item?
Current option item with vale "0" still showing in the drop down box.

Thanks.

Re: Remove (disable) out of stock items

Posted: Sat Dec 04, 2010 10:52 am
by jamesw
nakz wrote:Thanks Qphoria!
How do I disable this for "Option" item?
Current option item with vale "0" still showing in the drop down box.

Thanks.
Yes I have the same issue - is there a simple way to make 'options values' not in stock not display on the dropdown?

Re: Remove (disable) out of stock items

Posted: Tue Apr 26, 2011 4:26 am
by egejo
Please I'm having and issue when I do this mod after editing the catalog/model/catalog/product.php
and replacing all the p.status = '1' as told... the out of stock items stop displaying but the search function stops working and I'm getting this message when I do a search:

Code: Select all

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'p.status = '1' AND p.quantity > '0' AND p.date_available <= NOW()' at line 1
Error No: 1064
SELECT COUNT(*) AS total FROM product p LEFT JOIN product_description pd ON (p.product_id = pd.product_id) LEFT JOIN product_tags pt ON (p.product_id = pt.product_id) LEFT JOIN product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN manufacturer m ON (p.manufacturer_id = m.manufacturer_id) LEFT JOIN stock_status ss ON (p.stock_status_id = ss.stock_status_id) WHERE pd.language_id = '2' AND p2s.store_id = '0' AND ss.language_id = '2' AND pt.language_id = '2' AND (LCASE(pt.tag) = 'i4' OR LCASE(pt.tag) = 'i4') p.status = '1' AND p.quantity > '0' AND p.date_available <= NOW()
Please help me I need this mod but can't afford to loose searching capabilities neither.
Thanks for the help in advance

Re: Remove (disable) out of stock items

Posted: Sat May 07, 2011 8:36 am
by maperdel
Your query is lacking an 'AND' before the 'p.status = '1'' string...it should say AND p.status = '1'

Best.

Re: Remove (disable) out of stock items

Posted: Tue Sep 27, 2011 8:18 pm
by StudioImpact
Hi,
Love this simple fix which makes perfect sense to me, and I thought a client wanted it, but as it turns out he just added a lot of "coming soon" products with quantity of 0, and he does want to display these items of course. Is there a way to show coming soon, and not show out of stock?

edit: it concerns OpenCart v1.4.9.1. additional, we have 4 statusses for products: in stock, out of stock, coming soon, not online available (i'm new to OpenCart and working on an existing shop I'm not even sure if this is default or personalized) obviously i only want out of stock disabled.

Re: Remove (disable) out of stock items

Posted: Fri Sep 30, 2011 2:50 pm
by shiokguy
Dear all
How about having the ADD to Cart Graphic change to SOLD OUT Graphic?

I am using 1.5.1.1
Anyone can help me in doing this?

Regards
Shiok Guy

Re: Remove (disable) out of stock items

Posted: Sat Oct 29, 2011 12:22 am
by proveyourselfthom
I totally agree with sgfx, it should be an option in admin. It's hard to update when you do changes to the core.

Or maybe it would be great to display the product (product's profile, in search, etc) and instead of allow users to click on "Add to Cart", it should show up a message. "Unavailable product", "No longer available" or something like that.

I don't understand why users can add unavailable products to the cart with System => Settings => Option => Stock Checkout disabled.

Using version 1.5.1.2 here.

Thank you.

Re: Remove (disable) out of stock items

Posted: Sat Oct 29, 2011 2:00 am
by proveyourselfthom
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.

Re: Remove (disable) out of stock items

Posted: Mon Oct 31, 2011 8:35 pm
by proveyourselfthom
Unfortunately, it can't be made changing template files... You can't check the stock on /www/megaminiaturas/catalog/view/theme/megaminiaturas/template/product/category.tpl. I'll need to do changes in OpenCart's core.
Any alternative?
Thanks :(

Re: Remove (disable) out of stock items

Posted: Mon Nov 07, 2011 7:17 pm
by proveyourselfthom
vqmod has saved my life :)
But anyway, it would be great to have an admin option.
Thanks.

Re: Remove (disable) out of stock items

Posted: Tue Nov 22, 2011 3:12 pm
by pramathesh
I think there should be 2 options in the admin panel for out of stock items.

1. Remove Add to Cart Button - This will the add to cart button in the product page, category listing and remove the item in the featured list, Latest List etc.
2. Remove Listing - That will hide the product from the site.

Re: Remove (disable) out of stock items

Posted: Tue Nov 22, 2011 3:29 pm
by i2Paq
pramathesh wrote:2. Remove Listing - That will hide the product from the site.
Set the product inactive.