Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Add Customer Location and Date/Time Stamp to Customer Reviews

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 03-17-2008, 12:57 PM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default 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})
__________________
xcartmods.co.uk
Reply With Quote
  #2  
Old 03-17-2008, 04:09 PM
 
Duramax 6.6L Duramax 6.6L is offline
 

X-Adept
  
Join Date: Dec 2006
Posts: 865
 

Default 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.
__________________
Xcart 5.1.6 Building New Store
Xcart4.6.4 Gold Plus
Xcart 4.6.4 Platinum
Smart Template,
Mail Chimp Upgrade
Checkout One (One Page Checkout)
Checkout One X-Payments Connector
Checkout One Deluxe Tools
Call For Price
On Sale Module
Buy Together Module
MAP Price MOD
Reply With Quote
  #3  
Old 03-17-2008, 04:25 PM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default Re: Add Customer Location and Date/Time Stamp to Customer Reviews

Yes, go to General Settings ╩ Customer reviews options
__________________
xcartmods.co.uk
Reply With Quote
  #4  
Old 05-09-2008, 06:46 PM
 
sparker2 sparker2 is offline
 

eXpert
  
Join Date: Feb 2007
Posts: 290
 

Default Re: Add Customer Location and Date/Time Stamp to Customer Reviews

What about just adding the date and time? How can this be done?
__________________
Shareen
sparker2@cox.net
http://www.stitches4u.com
X-Cart Version 4.5.0 with Smart Template vs 4.4.x
Reply With Quote
  #5  
Old 10-22-2010, 01:39 PM
  dziner08's Avatar 
dziner08 dziner08 is offline
 

Newbie
  
Join Date: Mar 2008
Posts: 8
 

Default 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.
__________________
X-Cart 4.1.9
Reply With Quote
  #6  
Old 10-22-2010, 02:01 PM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default Re: Add Customer Location and Date/Time Stamp to Customer Reviews

Good catch, thanks dziner
__________________
xcartmods.co.uk
Reply With Quote
  #7  
Old 05-03-2011, 10:11 AM
  tqualizerman's Avatar 
tqualizerman tqualizerman is offline
 

X-Adept
  
Join Date: Jun 2008
Posts: 392
 

Default 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. :\
__________________
- www.nerdseven.com - Gadgets & Gizmos from Out of This World
- Sound Sensitive T-Shirts That Flash to the Beat of Music (http://www.tqualizer.com)


X-Cart Version 4.1.10
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Forum Jump


All times are GMT -8. The time now is 04:54 PM.

   

 
X-Cart forums © 2001-2020