VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: tonis on November 27, 2012, 10:41:25 AM

Title: Do not display products out of stock - when stock status is -1
Post by: tonis on November 27, 2012, 10:41:25 AM
Hello

By default the products can be disabled when their stock status is 0, but i need to display these products and need to disable products with stock status -1. I made same changes but thats not enough.

administrator/com_virtuemart/models/product.php

function sortSearchListQuery()

$where[] = ' (p.`product_in_stock` - p.`product_ordered` >"0" OR children.`product_in_stock` - children.`product_ordered` > "0") ';

changed to

$where[] = ' (p.`product_in_stock` - p.`product_ordered` >"-1" OR children.`product_in_stock` - children.`product_ordered` > "-1") ';



} else if (VmConfig::get('stockhandle','none')=='disableit') {
$where[] = ' p.`product_in_stock` - p.`product_ordered` >"0" ';

changed to

} else if (VmConfig::get('stockhandle','none')=='disableit') {
$where[] = ' p.`product_in_stock` - p.`product_ordered` >"-1" ';



case 'stockout':
$where[] = 'p.`product_in_stock`- p.`product_ordered` < 1';

changed to

case 'stockout':
$where[] = 'p.`product_in_stock`- p.`product_ordered` < 0';


public function getProduct()

if ($app->isSite () and VmConfig::get ('stockhandle', 'none') == 'disableit' and ($child->product_in_stock - $child->product_ordered) <= 0) {

changed to

if ($app->isSite () and VmConfig::get ('stockhandle', 'none') == 'disableit' and ($child->product_in_stock - $child->product_ordered) < 0) {



Now product with stock status 0 are displayed, and with -1 they are not ... but the product with 0 can't be addet to the cart, the add to cart button is not displayed ...

Someone who knows what else to change? Or some other solution for all this?

J2.5.8, VM2.0.14
   
Title: Re: Do not display products out of stock - when stock status is -1
Post by: tonis on November 27, 2012, 11:21:27 AM
another change ...

com_virtuemart/views/productdetails/tmpl/default_addtocart.php

if (($stockhandle == 'disableit' or $stockhandle == 'disableadd') and ($this->product->product_in_stock - $this->product->product_ordered) < 1) {
change to
if (($stockhandle == 'disableit' or $stockhandle == 'disableadd') and ($this->product->product_in_stock - $this->product->product_ordered) < 0) {

now the add to cart button is displayed, but it helps not, because the products with stock status 0 can't still not be addet do the cart