Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Modify the Write Reviews to Only Show First Name and then there Country Name

Modify the Write Reviews to Only Show First Name and then there Country Name

Views: 1,959

Results 1 to 4 of 4
16 Jun 2009, 3:07 AM
#1
idartsonline avatar

idartsonline

New Zenner

Join Date:
Jun 2008
Posts:
3
Plugin Contributions:
0

Modify the Write Reviews to Only Show First Name and then there Country Name

I have successfully modified the product_reviews_write (header_php.php) to have the first name on the posted review.:clap:

However, I have been unable to figure out how to add there Country Name (e.g. John - United Kingdom)

below is what i have done so far, if someone could lend a hand and help me out that would be greatly appreciated!

Thank you so much

Tina Marie :D

$zco_notifier->notify('NOTIFY_HEADER_START_PRODUCT_REVIEWS_WRITE');

if (!$_SESSION['customer_id']) {
  $_SESSION['navigation']->set_snapshot();
  zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
}

require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));

$product_info_query = "SELECT p.products_id, p.products_model, p.products_image,
                              p.products_price, p.products_tax_class_id, pd.products_name
                       FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                       WHERE p.products_id = :productsID
                       AND p.products_status = '1'
                       AND p.products_id = pd.products_id
                       AND pd.language_id = :languagesID";

$product_info_query = $db->bindVars($product_info_query, ':productsID', $_GET['products_id'], 'integer');
$product_info_query = $db->bindVars($product_info_query, ':languagesID', $_SESSION['languages_id'], 'integer');
$product_info = $db->Execute($product_info_query);

if (!$product_info->RecordCount()) {
  zen_redirect(zen_href_link(FILENAME_PRODUCT_REVIEWS, zen_get_all_get_params(array('action'))));
}

$customer_query = "SELECT customers_firstname, customers_lastname, customers_email_address
                   FROM " . TABLE_CUSTOMERS . "
                   WHERE customers_id = :customersID";


$customer_query = $db->bindVars($customer_query, ':customersID', $_SESSION['customer_id'], 'integer');
$customer = $db->Execute($customer_query);

if (isset($_GET['action']) && ($_GET['action'] == 'process')) {
  $rating = zen_db_prepare_input($_POST['rating']);
  $review_text = zen_db_prepare_input($_POST['review_text']);

  $error = false;
  if (strlen($review_text) < REVIEW_TEXT_MIN_LENGTH) {
    $error = true;

    $messageStack->add('review_text', JS_REVIEW_TEXT);
  }

  if (($rating < 1) || ($rating > 5)) {
    $error = true;

    $messageStack->add('review_text', JS_REVIEW_RATING);
  }

  if ($error == false) {
    if (REVIEWS_APPROVAL == '1') {
      $review_status = '0';
    } else {
      $review_status = '1';
    }

    $sql = "INSERT INTO " . TABLE_REVIEWS . " (products_id, customers_id, customers_name, reviews_rating, date_added, status)
            VALUES (:productsID, :customersID, :customersName, :rating, now(), " . $review_status . ")";


    $sql = $db->bindVars($sql, ':productsID', $_GET['products_id'], 'integer');
    $sql = $db->bindVars($sql, ':customersID', $_SESSION['customer_id'], 'integer');
    $sql = $db->bindVars($sql, ':customersName', $customer->fields['customers_firstname'] . ' ' . $customer->fields[''], 'string');
    $sql = $db->bindVars($sql, ':rating', $rating, 'string');

    $db->Execute($sql);
21 Jun 2009, 1:02 AM
#2
speedcreed avatar

speedcreed

New Zenner

Join Date:
Dec 2008
Posts:
85
Plugin Contributions:
0

Re: Modify the Write Reviews to Only Show First Name and then there Country Name

Hi Tina,

I can't help you with the Country name (wish I could) but just wanted to say 'Thanks' for posting your 'First Name Only' re-write of the review code. It was just what I was looking for and was very easy. I hope that someone more knowledgeble will answer your request for help.

Thanks again,
Tony

21 Jun 2009, 1:39 AM
#3
speedcreed avatar

speedcreed

New Zenner

Join Date:
Dec 2008
Posts:
85
Plugin Contributions:
0

Re: Modify the Write Reviews to Only Show First Name and then there Country Name

I did think of one additional thing that might be helpful: In order to make it clearer to customers that their last names will not appear on their review, the following file can be changed as follows: includes/languages/english/product_reviews_write.php

Change from this: ```php
define('SUB_TITLE_FROM', 'Written by:');


To this, or something similar:

```php
define('SUB_TITLE_FROM', 'Written by (Privacy Note: even though your full name is depicted below, only your first name will appear on your review): ');
23 Mar 2011, 2:16 AM
#4
jenred avatar

jenred

New Zenner

Join Date:
Jul 2004
Location:
Australia
Posts:
48
Plugin Contributions:
0

Re: Modify the Write Reviews to Only Show First Name and then there Country Name

I don't need the country included but I had a request from a client to only show the first name for reviews. Thanks to both of you for this - I had a bit of trouble with the code posted at the top though. In the end I just found this line in /includes/modules/pages/product_reviews_write/header_php.php:

   
 $sql = $db->bindVars($sql, ':customersName', $customer->fields['customers_firstname'] . ' ' . $customer->fields['customers_lastname'], 'string');
 

and changed it to:

    
$sql = $db->bindVars($sql, ':customersName', $customer->fields['customers_firstname'] . ' ' . $customer->fields[''], 'string'); 

For the reviews already in the system with a last name, I went into phpMyAdmin and found the reviews area and edited each one to remove the last name. There were only 5 so it was an easy job, not sure if there is a better way if you have lots of reviews already.

In includes/languages/english/product_reviews_write.php I did it slightly differently than above as I think it works better:

 
define('SUB_TITLE_FROM', 'Written by:');


define('SUB_TITLE_REVIEW', '<strong>Privacy Note: Even though your full name is displayed above, only your first name will appear on your published review.</strong><br><br>Please tell us what you think of this product and share your opinions with others. Be sure to focus your comments on the product.<br><br>');

Thanks

Jen