Page 1 of 2
[MOD] Out of stock status change automatic + hide cartbutton
Posted: Mon Oct 05, 2009 8:03 pm
by vimal
Does the out of stock status change automatic? I think it should by counting the number of products left. If it is 0 then the status should change automatically. It doesn't seem to do that. Is that a bug or is it just not working in my shop? I had to manually go and change it.
Is there a better way to handle it?
Re: Out of stock status change automatic?
Posted: Mon Oct 05, 2009 8:07 pm
by Qphoria
That is what it does for me. All automatic.
Re: Out of stock status change automatic?
Posted: Tue Oct 06, 2009 2:37 pm
by vimal
Any idea Qphoria why it doesn't change automatically for me? I keep the product status to "in stock" by default. I think earlier it was on out of stock by default.
Will it show "in stock" in the store If I change the status to "out of stock" and keep number of products more than 0?
Re: Out of stock status change automatic?
Posted: Tue Oct 06, 2009 3:58 pm
by gavin m
Is your out of stock status set to 'out of stock'? Sound slike you have set it to 'In Stock'
Re: Out of stock status change automatic?
Posted: Tue Oct 06, 2009 4:28 pm
by fido-x
You need to set the "Out Of Stock Status" on your product to "Out Of Stock". You'll find it under the "Data" tab.
You'll also need to ensure that "Stock Subtract" is set to "Yes" in your settings ("Admin->Configuration->Setting, under the "Option" tab).
Re: Out of stock status change automatic?
Posted: Tue Oct 06, 2009 5:59 pm
by vimal
Yep! got it..I had set my product status to "In stock" and stock substract to yes. I have changed the product status to out of stock and it is now working like it should.
Thanks all!
Vimal.
Re: Out of stock status change automatic?
Posted: Thu Dec 10, 2009 6:33 pm
by deeve
Apologies for opening this thread up again, but wondered whether it was possible for auto 'Out of Stock' option to actually not show the item until its quantity is adjusted [re-stocked]? Currently I get the item + 'Out of Stock' displayed but would prefer the item not appear until back in stock. Is this possible?
update: Just realized this is down to the 'Status enabled' not being set to 'false'. Can this be achieved automatically?
Thanks.
Re: Out of stock status change automatic?
Posted: Thu Dec 10, 2009 8:38 pm
by Qphoria
1. EDIT: catalog/model/catalog/product.php
2. FIND:
3. GLOBALLY REPLACE WITH:
Re: Out of stock status change automatic?
Posted: Thu Dec 10, 2009 10:13 pm
by deeve
Thanks once again, Q - you're a Star!
Re: Out of stock status change automatic?
Posted: Tue Jan 26, 2010 9:08 pm
by robisrob
Is it also possible to show only the optionsvalues of the products that are in stock. For example you have a shirt in size 36 and 38, but when 36 is out of stock you see only the option 38
Re: Out of stock status change automatic?
Posted: Wed Jan 27, 2010 1:24 am
by robisrob
I think I found it myself

.
I just add quantity>0 to the next rule in the same page as before.
$product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value WHERE product_option_id = '" . (int)$product_option['product_option_id'] . "'and quantity>0 ORDER BY sort_order");
Re: Out of stock status change automatic?
Posted: Wed Jan 27, 2010 2:56 am
by Qphoria
correct
Re: [MOD] Out of stock status change automatic?
Posted: Wed Jan 27, 2010 9:32 pm
by robisrob
Is their also a possibility so that the product that are out of stock aren't showed as best sales and latest products? Or which files do I need to adjust. Maybe then I can find it myself

Re: [MOD] Out of stock status change automatic?
Posted: Mon Mar 08, 2010 3:26 am
by nathalie
Thank you so much!
It works perfectly!

Re: [MOD] Out of stock status change automatic?
Posted: Mon Mar 08, 2010 4:25 am
by i2Paq
I think it would be also nice to have the Add to Cart button removed instead of the whole product.
Re: [MOD] Out of stock status change automatic?
Posted: Thu May 06, 2010 6:51 am
by padred123
i2Paq wrote:I think it would be also nice to have the Add to Cart button removed instead of the whole product.
This works for me. It removes the add to cart button if the stock is anything different than "In Stock".
Look in file:
catalog\view\theme\
"your_theme"\template\product\product.tpl
Find (around line 100):
Code: Select all
<div style="background: #F7F7F7; border: 1px solid #DDDDDD; padding: 10px;"><?php echo $text_qty; ?>
<input type="text" name="quantity" size="3" value="1" />
<a onclick="$('#product').submit();" id="add_to_cart" class="button"><span><?php echo $button_add_to_cart; ?></span> </a></div>
<input type="hidden" name="product_id" value="<?php echo $product_id; ?>" />
<input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />
</form>
Add this before the DIV tag:
Code: Select all
<?php if($stock == 'In Stock' || $stock > 0){ ?>
Add this before the FORM tag :
Result:
Code: Select all
<?php if($stock == 'In Stock' || $stock > 0){ ?>
<div style="background: #F7F7F7; border: 1px solid #DDDDDD; padding: 10px;"><?php echo $text_qty; ?>
<input type="text" name="quantity" size="3" value="1" />
<a onclick="$('#product').submit();" id="add_to_cart" class="button"><span><?php echo $button_add_to_cart; ?></span></a></div>
<input type="hidden" name="product_id" value="<?php echo $product_id; ?>" />
<input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />
<?php } ?>
</form>
Re: [MOD] Out of stock status change automatic + hide cartbu
Posted: Sun Jan 16, 2011 1:32 am
by schlegk
As someone mentioned earlier - I would like to simply have out of stock items not display. I have managed to do this with the change shown earlier in this thread, but the out of stock items are still showing up in Bestsellers and latest products. How can I fix this, please?
Thanks in advance!
Re: [MOD] Out of stock status change automatic + hide cartbu
Posted: Sun Mar 06, 2011 2:36 pm
by Sidecutter
Padred123, your code works perfectly, glad I found this thread.
It needs a little tweak for 1.4.9.3 though. The additions are the same, just the underlying code to be modified is different.
Look for this code:
Code: Select all
<div class="content">
<?php echo $text_qty; ?>
<input type="text" name="quantity" size="3" value="<?php echo $minimum; ?>" />
<a onclick="$('#product').submit();" id="add_to_cart" class="button"><span><?php echo $button_add_to_cart; ?></span></a>
<?php if ($minimum > 1) { ?><br/><small><?php echo $text_minimum; ?></small><?php } ?>
</div>
<div>
<input type="hidden" name="product_id" value="<?php echo $product_id; ?>" />
<input type="hidden" name="redirect" value="<?php echo str_replace('&', '&', $redirect); ?>" />
</div>
</form>
Add this before <div class="content">:
Code: Select all
<?php if($stock == 'In Stock' || $stock > 0){ ?>
Add this before </form>:
The result should be:
Code: Select all
<?php if($stock == 'In Stock' || $stock > 0){ ?>
<div class="content">
<?php echo $text_qty; ?>
<input type="text" name="quantity" size="3" value="<?php echo $minimum; ?>" />
<a onclick="$('#product').submit();" id="add_to_cart" class="button"><span><?php echo $button_add_to_cart; ?></span></a>
<?php if ($minimum > 1) { ?><br/><small><?php echo $text_minimum; ?></small><?php } ?>
</div>
<div>
<input type="hidden" name="product_id" value="<?php echo $product_id; ?>" />
<input type="hidden" name="redirect" value="<?php echo str_replace('&', '&', $redirect); ?>" />
</div>
<?php } ?>
</form>
Re: [MOD] Out of stock status change automatic + hide cartbu
Posted: Sun Apr 03, 2011 4:06 am
by nathalie
is it also possible that when you have different selections of a product, lets say, size S , M , L and S is sold out, that there's a automaticly a message saying S is sold out?
And how can I put another image over a sold out product? I'd like to create sticker saying "sold out".
Like this website
http://www.demo.opencart4u.com/ but here they dont have the option of sold out, only new/best products
Re: [MOD] Out of stock status change automatic + hide cartbu
Posted: Wed May 25, 2011 6:40 pm
by barblask
Code: Select all
<?php if($stock == 'In Stock' || $stock > 0){ ?>
It works only on standard englich translation. Bether is to make it in this way:
Code: Select all
if($stock == $this->language->get('text_instock') || $stock > 0){