Page 1 of 1

Allow only 1 bid per user per product

PostPosted: Wed Aug 17, 2011 7:14 pm
by cinto_qq
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

Re: Allow only 1 bid per user per product

PostPosted: Thu Aug 18, 2011 9:46 am
by shannah
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

Re: Allow only 1 bid per user per product

PostPosted: Thu Aug 18, 2011 11:38 pm
by cinto_qq
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