Basket solution

Imagine that a customer adds three modems to their shopping cart and continues browsing the site. And after a while, when he decided to place an order, there were 2 “Available” modems (one modem was bought by someone else). And in the basket he has 3 modems, now he will be able to place an order for 3 modems. And then in the field “In stock” the number will change to “-1″.

To prevent a person from placing an order for a larger number of goods than is in stock, you should always check for compliance after the user clicks the “Place an order” button: The number of goods indicated in the basket must not exceed the number specified in the “In Stock” field for one product. If it exceeds, then issue a message: “Such-and-such (specify here which product) goods in the warehouse: n pieces. Please change the quantity of goods in the field of the same name and click “recalculate” “.

In principle, I understand how to do it, we must, after clicking on the checkout button, call the database to compare the count. goods in the warehouse and the quantity in the basket, if they are >=, then the goods are processed, if <=, then it displays a message that “sorry blah blah blah”,
it’s just that I can’t write in the code.

Answer 1, authority 100%

$rate = $_POST['rate'];//   ,  
$artikul = $_POST['artikul']; // ( ID )
$result = mysql_query("SELECT rate FROM sklad WHERE artikul='$artikul';");//        
$a = mysql_fetch_array($result);
echo ",   $a['rate']   ";

Leave a reply

Please enter your comment!
Please enter your name here