Well the title kind of explains it. I'm running 1.3.4 version and would like to know if there's a way of getting stock to be disabled when they run out of stock. This would be really helpful, thanks.
There is no "disable product if out of stock" function. However, if you change the following lines in "catalog/controller/product/product.php" (lines 195 to 203) from:-
to:
Then, in "catalog/view/theme/default/template/product/product.tpl", change the following (lines 89 to 91) from:-
to:
The "Add to Cart" button will no longer appear on the page when a product is out of stock.
Code: Select all
if ($product_info['quantity'] <= 0) {
$this->data['stock'] = $product_info['stock'];
} else {
if ($this->config->get('config_stock_display')) {
$this->data['stock'] = $product_info['quantity'];
} else {
$this->data['stock'] = $this->language->get('text_instock');
}
}
Code: Select all
if ($product_info['quantity'] <= 0) {
$this->data['stock'] = $product_info['stock'];
$this->data['stock_level'] = FALSE;
} else {
if ($this->config->get('config_stock_display')) {
$this->data['stock'] = $product_info['quantity'];
$this->data['stock_level'] = TRUE;
} else {
$this->data['stock'] = $this->language->get('text_instock');
$this->data['stock_level'] = TRUE;
}
}
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>
Code: Select all
<?php if ($stock_level) { ?>
<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>
<?php } ?>
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
Oh ok cool fix, althought instead of just removing the button you could just make a non-clickable one saying "Out Of Stock"
OK then, try this. From the above post change:
to:
Code: Select all
<?php if ($stock_level) { ?>
<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>
<?php } ?>
Code: Select all
<div style="background: #F7F7F7; border: 1px solid #DDDDDD; padding: 10px;">
<?php if ($stock_level) { ?>
<?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>
<?php } else {?>
<a class="button"><span><?php echo $stock; ?></span></a>
<?php } ?>
</div>
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
Ah brilliant, i added in another CSS style to make the button red when out of stock too. Thanks
Although i think this function should already be implemented imho. But oh well
Thanks anyway
Although i think this function should already be implemented imho. But oh well

Who is online
Users browsing this forum: No registered users and 61 guests