VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Rune Rasmussen on August 11, 2022, 11:06:57 AM

Title: Sold out products being available to buy [VM 4.0.2]
Post by: Rune Rasmussen on August 11, 2022, 11:06:57 AM
Configuration:
Action when a Product is Out of Stock ->
Stockhandling on product level: No
Displays 'Notify Me' instead of 'Add To Cart' button

Even with the mentioned configuration we see from time to time that products end up being available to buy when they actually is out of stock.

This happens when they for some unknown reason sometimes ends up having a negative value on 'Booked, ordered' in 'Product Status'.

I guess it's two issues in this:


*Confirmed also with vmbeez3
Title: Re: Sold out products being available to buy [VM 4.0.2]
Post by: GJC Web Design on August 12, 2022, 12:32:45 PM
negative stock is created because the stock level is calc'd by  $product->product_in_stock - $product->product_ordered

in the model the decision to show the Notify button is decides by

($product->product_in_stock - $product->product_ordered) < $minOrderLevel  -> show notify

$minOrderLevel is either set as a product_params or defaults to 1

if ($child->min_order_level > 0) {
$minOrderLevel = $child->min_order_level;
} else {
$minOrderLevel = 1;
}

if (($stockhandle == 'disableit' or $stockhandle == 'disableadd') and ($child->product_in_stock - $child->product_ordered) < $minOrderLevel) {
$child->orderable = false;
$child->show_notify = true;
}


Title: Re: Sold out products being available to buy [VM 4.0.2]
Post by: Rune Rasmussen on August 12, 2022, 16:53:29 PM
Thanks, but it's the 'Booked, ordered' ending up being negative - and it puzzles me how that can happen.
Anyhow, if you have a stock of lets say 1 or 0, then -2 on 'Booked, ordered', we end up having a plus value in stock calculation...
Title: Re: Sold out products being available to buy [VM 4.0.2]
Post by: Studio 42 on August 12, 2022, 17:02:30 PM
Negative values are most time when you do not check for booked products when you add some stock for products
It's why VM Be pro support +1, +2 .... as import values and not only 1 or 2 to prevent this problem that most shop have
Title: Re: Sold out products being available to buy [VM 4.0.2]
Post by: Rune Rasmussen on August 12, 2022, 17:06:59 PM
Hm ... adding or changing stock shouldn't make booked negative, unless also booked are manually edited. Booked should reflect what's actually in orders, and should probably better not be possible to edit easily...