Dev Shed Lounge
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherDev Shed Lounge

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 19th, 2003, 02:54 PM
computer's Avatar
computer computer is offline
echo $usertitle['computer'];
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Jan 2003
Location: UK
Posts: 6,674 computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 4 Weeks 9 h 8 m 32 sec
Reputation Power: 219
Send a message via ICQ to computer
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
__________________

Reply With Quote
  #2  
Old June 19th, 2003, 03:16 PM
SilkySmooth's Avatar
SilkySmooth SilkySmooth is offline
Newbie :P
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2001
Location: In the PHP Engine :-)
Posts: 2,880 SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 11 h 32 m 23 sec
Reputation Power: 15
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

Reply With Quote
  #3  
Old June 19th, 2003, 04:05 PM
jpenn's Avatar
jpenn jpenn is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2002
Location: Washington, DC
Posts: 2,693 jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 41 m 10 sec
Reputation Power: 16
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

Reply With Quote
  #4  
Old June 20th, 2003, 05:28 AM
computer's Avatar
computer computer is offline
echo $usertitle['computer'];
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Jan 2003
Location: UK
Posts: 6,674 computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 4 Weeks 9 h 8 m 32 sec
Reputation Power: 219
Send a message via ICQ to computer
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...

Reply With Quote
  #5  
Old June 20th, 2003, 06:18 AM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Afghanistan
Posts: 14,382 Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 70626 Folding Title: Intermediate FolderFolding Points: 70626 Folding Title: Intermediate FolderFolding Points: 70626 Folding Title: Intermediate FolderFolding Points: 70626 Folding Title: Intermediate Folder
Time spent in forums: 2 Months 4 Weeks 11 h 1 m 51 sec
Reputation Power: 1784
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
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...

Reply With Quote
  #6  
Old June 20th, 2003, 09:24 AM
computer's Avatar
computer computer is offline
echo $usertitle['computer'];
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Jan 2003
Location: UK
Posts: 6,674 computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 4 Weeks 9 h 8 m 32 sec
Reputation Power: 219
Send a message via ICQ to computer
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?

Reply With Quote
  #7  
Old June 20th, 2003, 09:46 AM
SilkySmooth's Avatar
SilkySmooth SilkySmooth is offline
Newbie :P
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2001
Location: In the PHP Engine :-)
Posts: 2,880 SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 11 h 32 m 23 sec
Reputation Power: 15
Quote:
Originally posted by SepodatiCreations
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"...


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.

Reply With Quote
  #8  
Old June 20th, 2003, 12:57 PM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Afghanistan
Posts: 14,382 Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 70626 Folding Title: Intermediate FolderFolding Points: 70626 Folding Title: Intermediate FolderFolding Points: 70626 Folding Title: Intermediate FolderFolding Points: 70626 Folding Title: Intermediate Folder
Time spent in forums: 2 Months 4 Weeks 11 h 1 m 51 sec
Reputation Power: 1784
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
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...

Reply With Quote
  #9  
Old June 20th, 2003, 01:00 PM
computer's Avatar
computer computer is offline
echo $usertitle['computer'];
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Jan 2003
Location: UK
Posts: 6,674 computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 4 Weeks 9 h 8 m 32 sec
Reputation Power: 219
Send a message via ICQ to computer
the checkout idea sounds best. i'll talk with the others.

meanwhile, i've got tons of coding to do

comp

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherDev Shed Lounge > freezing stock levels


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |