VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: G. Billionaire on January 06, 2013, 19:08:14 PM

Title: Checking Stock Quantities are incorrect after item is ordered
Post by: G. Billionaire on January 06, 2013, 19:08:14 PM
/components/com_virtuemart/helpers/cart.php
Line 650
$productsleft = $product->product_in_stock - $product->product_ordered;

When checking for stock is enabled and a customer tries to add/update a product in the cart, an error message comes up stating that the product is out of stock.
Here is the test case:
If there were 15 shirts in stock
Then some one ordered 5
That Leaves 10. This is fine once the owner of the shop doesnt get more shirts in stock.

If the owner gets 5 more shirts in stock, and goes to the admin area and adds the 5 shirts. The new total shirts in stock is 15 again.
Here is the problem:
Because the stock was replenished the  $product->product_in_stock = 15.
And the $product->product_ordered still = 5 because of the previous order.
Now if a new customer tries to order 15 shirts(the replenished value), They Cant!!
They can only order 10  because of the line of code:
$productsleft = $product->product_in_stock - $product->product_ordered;

$productsleft = 15 - 5
Title: Re: Checking Stock Quantities are incorrect after item is ordered
Post by: Milbo on January 06, 2013, 22:34:26 PM
Absolutly correct, yes.
If you want to "free" the booked products you must set your orders to cancelled or refund,.. etc (you can configure this per orderstatus)