Menu

Updating stock in stats.php

2003-10-05
2003-10-05
  • jeroen van den bosch

    Due to the problems i ran in to with the virtual stock, I came to the conculsion that size.stock was updated to soon.( for me it was )
    so I took alook at cart.php and stats.php and i saw that size.stock was updated as soon as costumers added a product in their carts.
    When the costumers leave the site before the order was placed the stock was updated but nothing sold.
    This way some products where -250 on stock......

    Now I've implanted a function into stats.php witch is called upon when the order did take place.....

    I also deleted the size update queries(3 of them) in cart.php so that function isn't working anymore.

    this is what I added into stats.php( just behind the statistics update query) to get it working:

    $itemID_res = db_query("select ID from item where number=$item_number") or db_die();
    $itemID_row = db_fetch_row($itemID_res);
    $itemID = $itemID_row[0];       

    $stock_res = db_query("select stock,expiration from size where itemID=$itemID") or db_die();
    $stock_row = db_fetch_row($stock_res);
    $newstock = $stock_row[0] - $quantity;   

            $size_res = db_query("update size set stock=$newstock WHERE itemID=$itemID") or die(mysql_error());

    Best regards,

    Jeroen

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.