Allow only 1 bid per user per product

A place to discuss and receive support for the Web Auction application.

Allow only 1 bid per user per product

Postby cinto_qq » Wed Aug 17, 2011 7:14 pm

Hi,

We would like to allow each user to only bid once for the product. How can we go about doing that?

Thanks!


Cheers,
Cinto
cinto_qq
 
Posts: 12
Joined: Wed Aug 17, 2011 6:58 pm

Re: Allow only 1 bid per user per product

Postby shannah » Thu Aug 18, 2011 9:46 am

1. Create a function that checks if a user has bid on a product already.
2. Add checks in the product template and in the bid permissions to make sure that the user hasn't bid on a product. The customization is almost the same as that described at viewtopic.php?f=5&t=6189#p28411 . The difference is that you'll be checking based on whether the user has bid whereas that thread is just checking based on a field in the users table.

Important Note: The getPermissions() method is called MANY TIMES per request. Therefore you should not to anything timeconsuming in these methods. If you need to put a check of any kind in here, make sure you do it in such a way that any sql queries are only run once or twice per request and are retrieved from a cache the rest of the time. E.g. rather than running a query each time to see if the user has bid on the product already - the first time the function is run you could just load all of the product ids that the user has bid on into an array . then you could check that array each time thereafter.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Allow only 1 bid per user per product

Postby cinto_qq » Thu Aug 18, 2011 11:38 pm

Hi Steve,

Thanks for the explanation.

I have created the functions to check the bids, but I am not very sure of what to do with the permissions. The functions will check whether the user has already bid for the particular product. Do I still need to add any checks or functions in the bid permissions?


Cheers,
Cinto
cinto_qq
 
Posts: 12
Joined: Wed Aug 17, 2011 6:58 pm


Return to Web Auction Discussion

Who is online

Users browsing this forum: No registered users and 20 guests

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved