Only allow customer to write a review once for any product
WillemB <[email protected]> 1 Sep 2003 21:57:33 -0000
| Newsgroups | gmane.comp.web.oscommerce.tips |
|---|---|
| Message-ID | <6fbb4810062b5e4f3eef97993b168dc3@osCommerce-Forums> |
This message was sent from: Tips and Tricks
http://forums.oscommerce.com/viewtopic.php?p=222930#222930
----------------------------------------------------------------
I thought I'd make a little contribution, considering this has given me quite a headache this afternoon.
I found out that writing a review for a product can be done regardless of previously written reviews by the same customer, thus allowing annoying teenagers to submit "this products sux big time don't buy" hundreds of times.
With an easy tweak it's a problem of the past:
In /catalog/product_reviews_write.php, look for [quote] if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process')) {
$rating = tep_db_prepare_input($HTTP_POST_VARS['rating']);
$review = tep_db_prepare_input($HTTP_POST_VARS['review']);
$error = false;[/quote]
Below this lines, you can add this: [quote] $Temp1 = (int)$product_info['products_id'];
$Temp2 = (int)$customer_id;
$unique_query = tep_db_query("select customers_id from reviews where products_id = " . $Temp1 . " and customers_id = " . $Temp2);
$Temp3 = tep_db_fetch_array($unique_query);
if ($Temp3[customers_id] == $customer_id )
{
$error = true;
$messageStack->add('review', 'Only one entry allowed.');
}
[/quote]
Simply change 'Only one entry allowed.' to the warning message you want to appear. In my case it's hardcoded but you could of course take the better approach.
In anycase this code snippet should no longer allow any customer to make more than one review for any given product.
I'd appreciate it if you let me know whether or not you found this useful and if it works for you.