News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Checking Stock Quantities are incorrect after item is ordered

Started by G. Billionaire, January 06, 2013, 19:08:14 PM

Previous topic - Next topic

G. Billionaire

/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

Milbo

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)
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/