X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Add Customer Location and Date/Time Stamp to Customer Reviews (https://forum.x-cart.com/showthread.php?t=38371)

PhilJ 03-17-2008 12:57 PM

Add Customer Location and Date/Time Stamp to Customer Reviews
 
eg.
Author: Joe Bloggs
Location: London
Posted: 17-03-2008 23:28:56
Message: Blah blah blah

1) Apply this SQL patch...
Code:

ALTER TABLE `xcart_product_reviews` ADD `location` TEXT NOT NULL ;
ALTER TABLE `xcart_product_reviews` ADD `add_date` INT( 11 ) DEFAULT '0' NOT NULL ;
INSERT INTO xcart_languages SET code='US', name='lbl_review_your_location', value='Your location', topic='Labels';
INSERT INTO xcart_languages SET code='US', name='lbl_review_location', value='Location', topic='Labels';
INSERT INTO xcart_languages SET code='US', name='lbl_review_posted', value='Posted', topic='Labels';

2) In /vote.php

Replace...
Code:

  db_query ("INSERT INTO $sql_tbl[product_reviews] (remote_ip, email, message, productid) VALUES ('$REMOTE_ADDR', '$review_author', '$review_message', '$productid')");
With...
Code:

  db_query ("INSERT INTO $sql_tbl[product_reviews] (remote_ip, email, message, productid, location, add_date) VALUES ('$REMOTE_ADDR', '$review_author', '$review_message', '$productid', '$review_location', '".time()."')");
3a) /skin1/modules/Customer_Reviews/reviews.tpl

Replace...

Code:

<td colspan="2"><br /><b>{$lng.lbl_author}: {$r.email|default:$lng.lbl_unknown}</b><br />{$r.message|replace:"\n":"<br />"}<br /><br /></td>
With...
Code:

<td colspan="2"><br /><b>{$lng.lbl_author}:</b> {$r.email|default:$lng.lbl_unknown}<br />
{if $r.location ne ""}<b>{$lng.lbl_review_location}:</b> {$r.location}<br />{/if}
{if $r.add_date ne 0}<b>{$lng.lbl_review_posted}:</b> {$r.add_date|date_format:$config.Appearance.datetime_format}<br />{/if}
{$r.message|replace:"\n":"<br />"}<br /><br /></td>

3b) /skin1/modules/Customer_Reviews/reviews.tpl

Before...

Code:

<tr>
 <td class="FormButton">{$lng.lbl_your_message}:</td>

Insert...
Code:

<tr>
 <td width="20%" class="FormButton">{$lng.lbl_review_your_location}:</td>
 <td width="10" align="center">&nbsp;</td>
 <td width="80%"><input type="text" size="24" maxlength="100" name="review_location" id="review_location" {if $login ne ""}value="{$customer_info.b_city|escape}"{else}value="{$review.location|escape}"{/if} /></td>
</tr>

3c) /skin1/modules/Customer_Reviews/reviews.tpl

Removal of this code is recommended, as it auto-populates the customer email address into the name field (if customer is logged in).
Code:

({$customer_info.email|escape})
8O

Duramax 6.6L 03-17-2008 04:09 PM

Re: Add Customer Location and Date/Time Stamp to Customer Reviews
 
Is there a way to make sure a customer is logged in to leave a review.

PhilJ 03-17-2008 04:25 PM

Re: Add Customer Location and Date/Time Stamp to Customer Reviews
 
Yes, go to General Settings ╩ Customer reviews options

sparker2 05-09-2008 06:46 PM

Re: Add Customer Location and Date/Time Stamp to Customer Reviews
 
What about just adding the date and time? How can this be done?

dziner08 10-22-2010 01:39 PM

Re: Add Customer Location and Date/Time Stamp to Customer Reviews
 
Sorry to bump an old thread, but I thought I should bring up a slight vulnerability in your code. The Location Field is not being escaped for html input, which could lead to all sorts of havoc if your reviews are not moderated.

To fix this, Search for
Code:

$review_message = htmlspecialchars(trim($review_message));
And replace it with
Code:

$review_message = htmlspecialchars(trim($review_message));
$review_location = htmlspecialchars(trim($review_location));


Thanks for sharing your code, and I hope my modification can save some people from a potential headache. The internet can be a dangerous place.

PhilJ 10-22-2010 02:01 PM

Re: Add Customer Location and Date/Time Stamp to Customer Reviews
 
Good catch, thanks dziner :)

tqualizerman 05-03-2011 10:11 AM

Re: Add Customer Location and Date/Time Stamp to Customer Reviews
 
Has anyone adapted this code to work with 4.4x? My attempts have all failed. :\


All times are GMT -8. The time now is 11:56 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.