| 
	
 | 
 Posted by Rik on 05/28/06 14:47 
Dynamo wrote: 
> Hi again, 
> I am constructing a site on a small scale where people can buy nik 
> naks and pay for them via paypal. Everything works fine unless there 
> is only one of an item left for sale. What if 2 people try to buy 
> this item at the same time? 
> I have partially overcome this problem by adding an extra column 
> called status to my catalogue table. When somebody tries to buy the 
> item I have created an interim page where the user is asked to 
> confirm his purchase before sending the info to paypal and I have 
> inserted an update query that changes the status from "available" to 
> "pending sale" on this page. 
 
I expect you keep the data of (to be) purchased items in some kind of 
session. 
If you choose to store this session in the database instead of the default 
handler: 
- You could check wether a product is available by looking at stock minus 
the amount in the (several) session. 
- Other people will immediately see that an item is out of stock, or perhaps 
"reserved" if you choose to. 
- As soon as their purchase is aborted or time out after a arbitrary amount 
of time, items are available again. 
 
Grtz, 
--  
Rik Wasmus
 
  
Navigation:
[Reply to this message] 
 |