Administrator
- Join Date:
- Sep 2009
- Location:
- Stuart, FL
- Posts:
- 14,137
- Plugin Contributions:
- 56
Reviews - Updated [Support Thread]
If you'll post your version of /includes/modules/pages/product_reviews_write/header_php.php, perhaps I could help ...
Administrator
If you'll post your version of /includes/modules/pages/product_reviews_write/header_php.php, perhaps I could help ...
New Zenner
Thanks!
<?php
/**
* reviews Write
*
* @package page
* @copyright Copyright 2003-2012 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version GIT: $Id: Author: DrByte Sat Jul 21 16:05:31 2012 -0400 Modified in v1.5.1 $
*/
/**
* Header code file for product reviews "write" page
*/
// This should be first line of the script:
$zco_notifier->notify('NOTIFY_HEADER_START_PRODUCT_REVIEWS_WRITE');
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
if (REVIEWS_BY_GUESTS != '1' && !$_SESSION['customer_id']) {
$_SESSION['navigation']->set_snapshot();
$messageStack->add_session('header', MESSAGE_REVIEW_WRITE_NEEDS_LOGIN, 'caution');
zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
}
$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'))));
}
if (!$_SESSION['customer_id']) {
$customer = '';
} else {
$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);
}
$error = false;
if (isset($_GET['action']) && ($_GET['action'] == 'process')) {
$rating = zen_db_prepare_input($_POST['rating']);
$review_text = zen_db_prepare_input($_POST['review_text']);
$antiSpam = isset($_POST['should_be_empty']) ? zen_db_prepare_input($_POST['should_be_empty']) : '';
$zco_notifier->notify('NOTIFY_REVIEWS_WRITE_CAPTCHA_CHECK');
$review_name = zen_db_prepare_input($_POST['review_name']);
if ((strlen($review_name) < REVIEW_NAME_MIN_LENGTH) && (!$_SESSION['customer_id'])) {
$error = true;
$messageStack->add('review_text', JS_REVIEW_NAME);
}
if (strlen($review_text) < REVIEW_TEXT_MIN_LENGTH) {
$error = true;
$messageStack->add('review_text', MESSAGE_REVIEW_TEXT_MIN_LENGTH);
}
if (($rating < 1) || ($rating > 5)) {
$error = true;
$messageStack->add('review_text', JS_REVIEW_RATING);
}
if ($error == false) {
if ($antiSpam != '') {
$zco_notifier->notify('NOTIFY_SPAM_DETECTED_DURING_WRITE_REVIEW');
$messageStack->add_session('header', (defined('ERROR_WRITE_REVIEW_SPAM_DETECTED') ? ERROR_WRITE_REVIEW_SPAM_DETECTED : 'Thank you, your post has been submitted for review.'), 'success');
} else {
if (REVIEWS_APPROVAL == '1') {
$review_status = '0';
} else {
$review_status = '1';
}
$messageStack->add_session('header', REVIEWS_APPROVAL == '1' ? MESSAGE_REVIEW_SUBMITTED_APPROVAL : MESSAGE_REVIEW_SUBMITTED, 'success');
$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');
if (!$_SESSION['customer_id']) {
$sql = $db->bindVars($sql, ':customersID', 0, 'integer');
$sql = $db->bindVars($sql, ':customersName', $review_name, 'string');
} else {
$sql = $db->bindVars($sql, ':customersID', $_SESSION['customer_id'], 'integer');
$sql = $db->bindVars($sql, ':customersName', $customer->fields['customers_firstname'] . ' ' . substr( $customer->fields['customers_lastname'], 0, 1) . '.', 'string');
}
$sql = $db->bindVars($sql, ':rating', $rating, 'string');
$db->Execute($sql);
$insert_id = $db->Insert_ID();
$sql = "INSERT INTO " . TABLE_REVIEWS_DESCRIPTION . " (reviews_id, languages_id, reviews_text)
VALUES (:insertID, :languagesID, :reviewText)";
$sql = $db->bindVars($sql, ':insertID', $insert_id, 'integer');
$sql = $db->bindVars($sql, ':languagesID', $_SESSION['languages_id'], 'integer');
$sql = $db->bindVars($sql, ':reviewText', $review_text, 'string');
$db->Execute($sql);
// send review-notification email to admin
if (REVIEWS_APPROVAL == '1' && SEND_EXTRA_REVIEW_NOTIFICATION_EMAILS_TO_STATUS == '1' and defined('SEND_EXTRA_REVIEW_NOTIFICATION_EMAILS_TO') and SEND_EXTRA_REVIEW_NOTIFICATION_EMAILS_TO !='') {
$email_text = sprintf(EMAIL_PRODUCT_REVIEW_CONTENT_INTRO, $product_info->fields['products_name']) . "\n\n" ;
$email_text .= sprintf(EMAIL_PRODUCT_REVIEW_CONTENT_DETAILS, $review_text)."\n\n";
$email_subject = sprintf(EMAIL_REVIEW_PENDING_SUBJECT,$product_info->fields['products_name']);
$html_msg['EMAIL_SUBJECT'] = sprintf(EMAIL_REVIEW_PENDING_SUBJECT,$product_info->fields['products_name']);
$html_msg['EMAIL_MESSAGE_HTML'] = str_replace('\n','',sprintf(EMAIL_PRODUCT_REVIEW_CONTENT_INTRO, $product_info->fields['products_name']));
$html_msg['EMAIL_MESSAGE_HTML'] .= '<br />';
$html_msg['EMAIL_MESSAGE_HTML'] .= str_replace('\n','',sprintf(EMAIL_PRODUCT_REVIEW_CONTENT_DETAILS, $review_text));
if ($customer) {
$extra_info=email_collect_extra_info($name,$email_address, $customer->fields['customers_firstname'] . ' ' . $customer->fields['customers_lastname'] , $customer->fields['customers_email_address'] );
$html_msg['EXTRA_INFO'] = $extra_info['HTML'];
}
zen_mail('', SEND_EXTRA_REVIEW_NOTIFICATION_EMAILS_TO, $email_subject ,
$email_text . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'reviews_extra');
}
// end send email
}
zen_redirect(zen_href_link(FILENAME_PRODUCT_REVIEWS, zen_get_all_get_params(array('action'))));
}
}
$products_price = zen_get_products_display_price($product_info->fields['products_id']);
$products_name = $product_info->fields['products_name'];
if ($product_info->fields['products_model'] != '') {
$products_model = '<br /><span class="smallText">[' . $product_info->fields['products_model'] . ']</span>';
} else {
$products_model = '';
}
// set image
// $products_image = $product_info->fields['products_image'];
if ($product_info->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') {
$products_image = PRODUCTS_IMAGE_NO_IMAGE;
} else {
$products_image = $product_info->fields['products_image'];
}
$breadcrumb->add(NAVBAR_TITLE);
// This should be last line of the script:
$zco_notifier->notify('NOTIFY_HEADER_END_PRODUCT_REVIEWS_WRITE');
New Zenner
I don't think it's in my database, so I think that's why it isn't working, I couldn't remember if I ever uploaded the sql file but when I just tried I got a error "WARNING: An Error occurred, please refresh the page and try again.", the log says "[18-Jan-2014 15:01:05] PHP Fatal error: 1062:Duplicate entry 'REVIEWS_BY_GUESTS' for key 'unq_config_key_zen' :: INSERT INTO configuration ( configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, use_function, set_function) VALUES ( "Enable product reviews by guests?", "REVIEWS_BY_GUESTS", "1", "Identifies whether (1) or not (0) your store allows guests to write reviews.", 18, 63, NOW(), NULL, "zen_cfg_select_option(array('1', '0')," ), ( "Product Review Write - Guest Reviewer Name", "REVIEW_NAME_MIN_LENGTH", 5, "Minimum length of a guest reviewer's name", 2, 14, NOW(), NULL, NULL ); in /hsphere/local/home/tom97zr2/cardiozonetreadmills.com/includes/classes/db/mysql/query_factory.php on line 120
" But I don't see any of this in the database for the the configuration title and key, and here is the sql file below. does this file look right? thanks.
INSERT INTO configuration
( configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, use_function, set_function)
VALUES
( "Enable product reviews by guests?", "REVIEWS_BY_GUESTS", "1", "Identifies whether (1) or not (0) your store allows guests to write reviews.", 18, 63, NOW(), NULL, "zen_cfg_select_option(array('1', '0')," ),
( "Product Review Write - Guest Reviewer Name", "REVIEW_NAME_MIN_LENGTH", 5, "Minimum length of a guest reviewer's name", 2, 14, NOW(), NULL, NULL );
Administrator
The header_php.php file that you posted is the version that comes with the plugin. When you installed "Reviews by Guests", did you possibly rename the original file to something like header_php_original.php, keeping the .php extension?
For the /includes/modules/pages directory, Zen Cart automatically loads all files that match the template header_php*.php, so it's a good habit to get into to rename these file copies to something like header_php.php.original (so they don't keep the .php extension).
Administrator
tom97zr2:
I don't think it's in my database, so I think that's why it isn't working, I couldn't remember if I ever uploaded the sql file but when I just tried I got a error "WARNING: An Error occurred, please refresh the page and try again.", the log says "[18-Jan-2014 15:01:05] PHP Fatal error: 1062:Duplicate entry 'REVIEWS_BY_GUESTS' for key 'unq_config_key_zen' :: INSERT INTO configuration ( configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, use_function, set_function) VALUES ( "Enable product reviews by guests?", "REVIEWS_BY_GUESTS", "1", "Identifies whether (1) or not (0) your store allows guests to write reviews.", 18, 63, NOW(), NULL, "zen_cfg_select_option(array('1', '0')," ), ( "Product Review Write - Guest Reviewer Name", "REVIEW_NAME_MIN_LENGTH", 5, "Minimum length of a guest reviewer's name", 2, 14, NOW(), NULL, NULL ); in /hsphere/local/home/tom97zr2/cardiozonetreadmills.com/includes/classes/db/mysql/query_factory.php on line 120
" But I don't see any of this in the database for the the configuration title and key, and here is the sql file below. does this file look right? thanks.INSERT INTO configuration
( configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, use_function, set_function)
VALUES
( "Enable product reviews by guests?", "REVIEWS_BY_GUESTS", "1", "Identifies whether (1) or not (0) your store allows guests to write reviews.", 18, 63, NOW(), NULL, "zen_cfg_select_option(array('1', '0')," ),
( "Product Review Write - Guest Reviewer Name", "REVIEW_NAME_MIN_LENGTH", 5, "Minimum length of a guest reviewer's name", 2, 14, NOW(), NULL, NULL );
This file is what ships with the plugin; the "Enable product reviews by guests?" shows up in Configuration->Product Info and "Product Review Write - Guest Reviewer Name" shows up in Configuration->Minimum Values.
New Zenner
Yes I did do that! So that's probably the problem, let me fix that and see. Thanks a lot!
New Zenner
Sweet that fixed it, thanks a lot! I've done other renames live that in other folders, should I fix all those names too?
Totally Zenned
tom97zr2:
Sweet that fixed it, thanks a lot! I've done other renames live that in other folders, should I fix all those names too?
Yes you should.
She's bloody clever that Lat9 isn't she :smile:
Zen Follower
I see in earlier comments that the plugin needed some tweaking to be compatible with Zen Cart 1.5.1. I'm just curious if that's been done, yet or if there's a "beta" version for testing? We're obviously looking to potentially provide guests access to leave product reviews. Thank you.
////// **LeatherJacketMedia.com**
"I'm no Zen Cart expert, but I did sleep at a Holiday Inn Express last night."
Administrator
sportbiker:
I see in earlier comments that the plugin needed some tweaking to be compatible with Zen Cart 1.5.1. I'm just curious if that's been done, yet or if there's a "beta" version for testing? We're obviously looking to potentially provide guests access to leave product reviews. Thank you.
v1.1.0 (the current version) of this plugin has been compatible with Zen Cart v1.5.1 since September, 2012.
Zen Follower
Thanks for the information. I'm not sure how I didn't see that!
////// **LeatherJacketMedia.com**
"I'm no Zen Cart expert, but I did sleep at a Holiday Inn Express last night."
Administrator
No problem! Your question did cause me to go and verify that the plugin is also compatible with Zen Cart v1.5.2 and v1.5.3 ... and it is!
New Zenner
Can I Make The Review Show Up On The Product Page, like this site?
http://www.jjshouse.com/A-Line-Princess-Sweetheart-Asymmetrical-Tulle-Wedding-Dress-With-Lace-Beading-002011546-g11546#have_reviews
Administrator
andis02:
Can I Make The Review Show Up On The Product Page, like this site?
***Reviews -- Updated*** affects the review-writing process, not where the reviews are displayed. I'll second the answer given in your other posting: Use Tabbed Products Pro (TPP) -- it can display a tab that contains the product's reviews.
Totally Zenned
so here I am again asking the "odd" questions.. :) Love this mod.. anyway to replace the default stars graphics with Awesome Font glyphs?
My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.
Administrator
DivaVocals:
so here I am again asking the "odd" questions.. :) Love this mod.. anyway to replace the default stars graphics with Awesome Font glyphs?
Not currently ... let me see what's up. Do you have a sample glyph that you'd like to use?
Totally Zenned
lat9:
Not currently ... let me see what's up. Do you have a sample glyph that you'd like to use?I do indeed..
<i>class="fa fa-star"</i>
My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.
Totally Zenned
Question for you. this is so mch like the dgReviews which I love for 1.3.9 but I wasn hoping that there is a way to :
make a horizontal rule dividing the reviews below the description of the product. Also not have Featured review, to me it makes it look like one review is favored over another. I would like them all ( at least say up to 6) listed below the image.
The button to send to read all reviews...can it we get a write a review button also so the visiting customer can also write one if they wish, not be redirected to read them all.
Right now it looks like the review is part of the description.
Administrator
I'm a little confused; the "Reviews - Updated" plugin makes changes only to the product_reviews_write page. What you're describing are changes made to a product_info type page.
Totally Zenned
lat9:
I'm a little confused; the "Reviews - Updated" plugin makes changes only to the product_reviews_write page. What you're describing are changes made to a product_info type page.
aha!! so maybe it is like the buy now button or free shipping image area and can be relocated.
But still is there any way to list them all up to a set amount on the product page? Since the DG Reviews is no longer updated it would be great to merge your two mods.
Tell staff why this post should be reviewed.