一、zencart游客评论
1,直接显示评论框,在tpl_product_info_display.php调用代码:
<?php require($template->get_template_dir('tpl_ProductinfoReview.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_ProductinfoReview.php'); ?>
<br style="clear:both;" />
<?php require($template->get_template_dir('tpl_product_reviews_write_default.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_product_reviews_write_default.php'); ?>
注意:引用此段代码之后,还要将此文件中的</form>移到<!--eof Add to Cart Box-->后面。
2,修改tpl_product_reviews_write_default.php文件。默认这个文件会将产品的图片,名字,价格都显示出来。但是评论框就在此页显示,所以不需要,将其删掉。以及开头的<div id="reviewsWrite">和结尾的</div>也要删掉。至此之后,产品页面的详细评论是不是就正常了呢,没有。
3,页面会出现PHP的静态常量,类似SUB_TITLE_REVIEW这样的字段,这是因为没有声明,打开 includes/languages/english/你的模板目录/product_info.php,在里面加入以下代码:
//write review default
define('NAVBAR_TITLE', 'Reviews');
define('SUB_TITLE_FROM', 'Written by:');
define('SUB_TITLE_REVIEW', 'Please tell us what you think and share your opinions with others. Be sure to focus your comments on the product.');
define('SUB_TITLE_RATING', 'Choose a ranking for this item. 1 star is the worst and 5 stars is the best.');
define('TEXT_NO_HTML', '<strong>NOTE:</strong> HTML tags are not allowed.');
define('TEXT_BAD', 'Worst');
define('TEXT_GOOD', 'Best');
define('TEXT_PRODUCT_INFO', '');
define('TEXT_APPROVAL_REQUIRED', '<strong>NOTE:</strong> Reviews require prior approval before they will be displayed');
define('EMAIL_REVIEW_PENDING_SUBJECT','Product Review Pending Approval: %s');
define('EMAIL_PRODUCT_REVIEW_CONTENT_INTRO','A Product Review for %s has been submitted and requires your approval.'."\n\n");
define('EMAIL_PRODUCT_REVIEW_CONTENT_DETAILS','Review Details: %s');
define('TEXT_REVIEW_NAME', 'Your Name:');
define('TEXT_REVIEW_CONTENT', 'Your Reviews Content:');
define('TEXT_RATING', 'Rating:');
define('REVIEW_SUBMIT_BUTTON', 'Submit');
define('REVIEW_WRITE_SUCCESS', 'Your Reviews is success');
4,如果想要在产品页面直接提交评论的话,在includes/modules/pages/product_info/header_php.php 里面查找
if (!$_SESSION['customer_id']) {
$_SESSION['navigation']->set_snapshot();
}
在这段代码底下插入
//to write a guest review
if (isset($_POST['action']) && ($_POST['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);
}
// BOF Captcha
/* if (strtolower($_POST['indentifying_code'])!==strtolower($_SESSION['randCode']) && CAPTCHA_REVIEWS_WRITE == 'true')
{
$error = true;
$messageStack->add('review_text', ERROR_CAPTCHA);
} */
// EOF Captcha
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, ':rating', $rating, 'string');
if(!$_SESSION['customer_id']) {
$sql = $db->bindVars($sql, ':customersID', 0, 'integer');
$sql = $db->bindVars($sql, ':customersName', $_POST['review-name'], 'string');
} else {
$sql = $db->bindVars($sql, ':customersID', $_SESSION['customer_id'], 'integer');
$sql = $db->bindVars($sql, ':customersName', $_SESSION['customer_first_name'] . ' ' . $_SESSION['customer_last_name'], '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);
$messageStack->add('review_success', REVIEW_WRITE_SUCCESS, 'success');
echo "<script>alert(\"reviews success, it need approval \");</script>";
// 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));
$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
}
}
//eof write review
//******************************************************************************************
5,这样就会显示正常了,评论之后会进入审核。后台Catlog---Reviews 进行通过审核,如果想评论之后直接显示出来,不用审核,后台Configuration---Product Info---Product Reviews Require Approval 设置为0即可。
[最后编辑于 2016-12-05 16:54 ]
本文内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件至:admin@ptpc120.com 进行举报,并提供相关证据,工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。
请登录后评论~