|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
freezing stock levels
Hi,
Right, on my ecommerce site, we have a stock amount for each item. What we want is if a user adds it to his/her basket then the stock level will decrease, so another user cannot order the same product at the same time. However, if a user logs out or closes their browser then the stock is raised again. The problem is, is if a user closes their browser then the stock increases but if they leave it open and come back later it won't have timed out and raised so anothe could have of ordered it... How would i go about this? (PS: Using PHP/MySql) Get my jist? comp |
|
#2
|
||||
|
||||
|
Use Sessions!
Store the session id and each time a page is accessed by the user update a time field. Then a script that runns regularly to check for non movement, if a page hasn't been requested within a time period of 15 minutes then assume they have left, kill the session and release the stock.
__________________
--------------------- -- SilkySmooth -- --------------------- Proxy | Little Directory |
|
#3
|
||||
|
||||
|
puter - is there any reason why you are posting this in the lounge? Maybe Silkman can move it to the correct forum for archiving purposes...
![]()
__________________
~ Joe Penn |
|
#4
|
||||
|
||||
|
oops, i thought i was posting in the PHP forum...
umm, but i have been told that if a user leaves the basket a bit full and goes off for lunch and comes back later then they still have the stock so someone else cannot of bought it during the time they were away. um, is there any javascript (cross-browser) that detects when a user closes the browser... |
|
#5
|
||||
|
||||
|
This is a bad, bad, method, IMHO. Like you're finding out, there's no way to tell if the user closed the browser window, left for another site, or has it just sitting open on his desk while he "thinks"...
So what's to stop me from writing a little bot that goes through and loads up a web page with every product in your inventory... thus shutting you down? ---John Holmes... |
|
#6
|
||||
|
||||
|
nah, when you add it to the basket the site will decrease the stock levels. if you remove the product or update the QTY the stock levels would change. however.
perhaps using a mix of cookies and sessions that would track how long a user has been inactive and would reset the basket after like 1.5 hours or something? |
|
#7
|
||||
|
||||
|
Quote:
Well there is one way, using my method above in conjunction with some META REFRESH's set up for an interval just short of the deletion time you would be able to detect if the user was still present at the site because the refresh would force the time to be updated in the database and thus only people who have closed the browser or moved away from the site would loose there cart. No computer, don't just go for the easy option and delete after 1.5 hours, that is one method that really pisses me off. I have sat here before now looking around a computer store for a new motherboard and as you know, read through the specs etc takes time. Then in the middle of it I got called away for dinner. I got back and the twats had deleted my carrt which had around 12 items in at the time. I did not waste any further time at that store. The *proper* way to do this is not to track contents at the site but at checkout. If you have two concurrent users each purchasing productA but there is only 1 of this item. They both have it in their cart but personA is checking out and personB is still looking around the store. personA gets through and the stock is taken down by 1 thus leaving 0. By the time personB gets to checkout when he tries to go through check the stock levels and as it is now 0 inform him and stop him from continuing with the order. (This is the way larger companies set up because it also allows for back orders etc). Just my suggestions of the day. |
|
#8
|
||||
|
||||
|
You can't depend upon META REFRESH, though. I guess if you disabled it, then your cart would just get deleted after X hours.
Still wouldn't stop my bot from freezing your inventory acting like I want to buy something, though. I agree with Silky's last paragraph. Only decrease the stock when they actually check out. It depends on what kind of items we're talking about here and how much is usually stocked, but I'd say that once the stock level gets to a certain %, then upon checkout, the user is warned that X items could be placed on backorder or become unavailable. ---John Holmes... |
|
#9
|
||||
|
||||
|
the checkout idea sounds best. i'll talk with the others.
meanwhile, i've got tons of coding to do comp |
![]() |
| Viewing: Dev Shed Forums > Other > Dev Shed Lounge > freezing stock levels |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|