News:

Support the VirtueMart project and become a member

Main Menu

Do not display products out of stock - when stock status is -1

Started by tonis, November 27, 2012, 10:41:25 AM

Previous topic - Next topic

tonis

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
   

tonis

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