请问怎样实现访客能在商品页面评论、留言?

用于收藏精华贴子、网友共享的资料等。可以回复,不能发新贴。

版主: Jack

版面规则
本版面不能发新贴,可以回复

请问怎样实现访客能在商品页面评论、留言?

帖子uhjz » 2008-04-13 12:16

有一个评论模块,可惜要注册,太麻烦了。用户才没心情去注册完再问题.请大家帮想个办法,谢谢!
uhjz
普通会员
普通会员
 
帖子: 43
注册: 2007-10-21 20:25

Re: 请问怎样实现访客能在商品页面评论、留言?

帖子四海一家 » 2008-04-14 1:48

把那个模块,加一个访客留言。
四海一家
新手上路
新手上路
 
帖子: 8
注册: 2008-04-09 16:29

Re: 请问怎样实现访客能在商品页面评论、留言?

帖子Jack » 2008-04-14 9:04

有英文版的:http://www.zen-cart.com/index.php?main_page=product_contrib_info&products_id=206
头像
Jack
论坛版主
论坛版主
 
帖子: 12265
注册: 2004-12-16 10:04

Re: 请问怎样实现访客能在商品页面评论、留言?

帖子uhjz » 2008-04-14 18:10

我是想要有访客留言,但大家又能看到的,不是发邮件的。有什么好方法吗?如果要拿那个模块来改,又改怎么修改呢?谢谢。
uhjz
普通会员
普通会员
 
帖子: 43
注册: 2007-10-21 20:25

Re: 请问怎样实现访客能在商品页面评论、留言?

帖子Jack » 2008-04-15 7:46

把评论改为访客能评论就好了。(提醒:允许访客评论会导致很多垃圾评论)

/includes/templates/yourtemplate/templates/tpl_product_reviews_write_default.php
代码: 全选
<?php
/**
 * Page Template
 *
 * @package templateSystem
 * @copyright Copyright 2003-2006 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 $Id: tpl_product_reviews_write_default.php 4365 2006-09-03 19:16:58Z wilt $
 */
?>
<div class="centerColumn" id="reviewsWrite">
<?php echo zen_draw_form('product_reviews_write', zen_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, 'action=process&products_id=' . $_GET['products_id'], 'SSL'), 'post', 'onsubmit="return checkForm(product_reviews_write);"'); ?>
<!--bof Main Product Image -->
      <?php
        if (zen_not_null($products_image)) {
    ?>
  <div id="reviewWriteMainImage" class="centeredContent back"><?php
            /**
 * display the main product image
             */
   require($template->get_template_dir('/tpl_modules_main_product_image.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_main_product_image.php'); ?>
</div>
<?php
  //} else {
  ?>

<?php
        }
      ?>
<!--eof Main Product Image-->
<div class="forward">
<div id="reviewsWriteProductPageLink" class="buttonRow"><?php echo '<a href="' . zen_href_link(zen_get_info_page($_GET['products_id']), zen_get_all_get_params()) . '">' . zen_image_button(BUTTON_IMAGE_GOTO_PROD_DETAILS , BUTTON_GOTO_PROD_DETAILS_ALT) . '</a>'; ?></div>
<div class="buttonRow"><?php echo '<a href="' . zen_href_link(FILENAME_REVIEWS) . '">' . zen_image_button(BUTTON_IMAGE_REVIEWS, BUTTON_REVIEWS_ALT) . '</a>'; ?></div>
</div>

<h1 id="reviewsWriteHeading"><?php echo $products_name . $products_model; ?></h1>

<h2 id="reviewsWritePrice"><?php echo $products_price; ?></h2>
<?php
if ($_SESSION['customer_id']) {?>
<h3 id="reviewsWriteReviewer" class="">
    <?php echo SUB_TITLE_FROM, zen_output_string_protected($customer->fields['customers_firstname'] . ' ' . $customer->fields['customers_lastname']); ?>
    </h3>
    <?php } ?>
<br class="clearBoth" />

<?php if ($messageStack->size('review_text') > 0) echo $messageStack->output('review_text');
?>

<div id="reviewsWriteReviewsRate" class="center"><?php echo SUB_TITLE_RATING; ?></div>

<div class="ratingRow">
<?php echo zen_draw_radio_field('rating', '1', '', 'id="rating-1"'); ?>
<?php echo '<label class="" for="rating-1">' . zen_image($template->get_template_dir(OTHER_IMAGE_REVIEWS_RATING_STARS_ONE, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . OTHER_IMAGE_REVIEWS_RATING_STARS_ONE, OTHER_REVIEWS_RATING_STARS_ONE_ALT) . '</label> '; ?>

<?php echo zen_draw_radio_field('rating', '2', '', 'id="rating-2"'); ?>
<?php echo '<label class="" for="rating-2">' . zen_image($template->get_template_dir(OTHER_IMAGE_REVIEWS_RATING_STARS_TWO, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . OTHER_IMAGE_REVIEWS_RATING_STARS_TWO, OTHER_REVIEWS_RATING_STARS_TWO_ALT) . '</label>'; ?>

<?php echo zen_draw_radio_field('rating', '3', '', 'id="rating-3"'); ?>
<?php echo '<label class="" for="rating-3">' . zen_image($template->get_template_dir(OTHER_IMAGE_REVIEWS_RATING_STARS_THREE, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . OTHER_IMAGE_REVIEWS_RATING_STARS_THREE, OTHER_REVIEWS_RATING_STARS_THREE_ALT) . '</label>'; ?>

<?php echo zen_draw_radio_field('rating', '4', '', 'id="rating-4"'); ?>
<?php echo '<label class="" for="rating-4">' . zen_image($template->get_template_dir(OTHER_IMAGE_REVIEWS_RATING_STARS_FOUR, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . OTHER_IMAGE_REVIEWS_RATING_STARS_FOUR, OTHER_REVIEWS_RATING_STARS_FOUR_ALT) . '</label>'; ?>

<?php echo zen_draw_radio_field('rating', '5', '', 'id="rating-5"'); ?>
<?php echo '<label class="" for="rating-5">' . zen_image($template->get_template_dir(OTHER_IMAGE_REVIEWS_RATING_STARS_FIVE, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . OTHER_IMAGE_REVIEWS_RATING_STARS_FIVE, OTHER_REVIEWS_RATING_STARS_FIVE_ALT) . '</label>'; ?>
</div>

<label id="textAreaReviews" for="review-text"><?php echo SUB_TITLE_REVIEW; ?></label>
<?php echo zen_draw_textarea_field('review_text', 60, 5, '', 'id="review-text"');

if (!$_SESSION['customer_id']) {
    ?>
    <br />
<label id="textAreaNume" for="review-nume"><?php echo TEXT_REVIEW_NAME; ?></label>
<br />
<input type="text" name="review-nume" size = "33" maxlength = "62" id="review-nume" />
<?php
}

?>

    <div class="buttonRow forward"><?php echo zen_image_submit(BUTTON_IMAGE_SUBMIT, BUTTON_SUBMIT_ALT); ?></div>
<br class="clearBoth" />

<div id="reviewsWriteReviewsNotice" class="notice"><?php echo TEXT_NO_HTML . (REVIEWS_APPROVAL == '1' ? '<br />' . TEXT_APPROVAL_REQUIRED: ''); ?></div>
</form>
</div>


modules/pages/product_reviews_write/header.php
代码: 全选
<?php

$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']);
  $review_name = zen_db_prepare_input($_POST['review-nume']);

  $error = false;
  if ((strlen($review_name) < 3)&(!$_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', 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');
    if (!$_SESSION['customer_id']) {
        $sql = $db->bindVars($sql, ':customersID', 0, 'integer');
    }
    else{
    $sql = $db->bindVars($sql, ':customersID', $_SESSION['customer_id'], 'integer');
    }
    if (!$_SESSION['customer_id']) {
        $sql = $db->bindVars($sql, ':customersName', $review_name, 'string');
    }
    else
      {
    $sql = $db->bindVars($sql, ':customersName', $customer->fields['customers_firstname'] . ' ' .
        $customer->fields['customers_lastname'], '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));
      $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');
?>


modules/pages/product_reviews_write/jscript_main.php
代码: 全选
<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce                                       |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers                           |
// |                                                                      |
// | http://www.zen-cart.com/index.php                                    |
// |                                                                      |
// | Portions Copyright (c) 2003 osCommerce                               |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available through the world-wide-web at the following url:           |
// | http://www.zen-cart.com/license/2_0.txt.                             |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to       |
// | license@zen-cart.com so we can mail you a copy immediately.          |
// +----------------------------------------------------------------------+
// $Id: jscript_main.php 1105 2005-04-04 22:05:35Z birdbrain $
//
?>
<script language="javascript" type="text/javascript"><!--
var form = "";
var submitted = false;
var error = false;
var error_message = "";

function check_input(field_name, field_size, message) {
  if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
    var field_value = form.elements[field_name].value;

    if (field_value == '' || field_value.length < field_size) {
      error_message = error_message + "* " + message + "\n";
      error = true;
    }
  }
}

function check_radio(field_name, message) {
  var isChecked = false;

  if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
    var radio = form.elements[field_name];

    for (var i=0; i<radio.length; i++) {
      if (radio[i].checked == true) {
        isChecked = true;
        break;
      }
    }

    if (isChecked == false) {
      error_message = error_message + "* " + message + "\n";
      error = true;
    }
  }
}





function checkForm(form_name) {
  if (submitted == true) {
    alert("<?php echo JS_ERROR_SUBMITTED; ?>");
    return false;
  }
  form = form_name;
  error = false;
  error_message = "<?php echo JS_ERROR; ?>";


  check_input('review_text',"<?php echo REVIEW_TEXT_MIN_LENGTH; ?>","<?php echo JS_REVIEW_TEXT; ?>");
  check_input('review-nume',"<?php echo 3; ?>","<?php echo JS_REVIEW_NAME; ?>");
  check_radio("rating","<?php echo JS_REVIEW_RATING; ?>");

  if (error == true) {
    alert(error_message);
    return false;
  } else {
    submitted = true;
    return true;
  }
}

function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}
//--></script>


最后,在 includes/languages/english.php (以及相应中文语言文件)中加上
代码: 全选
define('JS_REVIEW_NAME', '* You have to complete your name.');
define('TEXT_REVIEW_NAME', 'Your Name:');
头像
Jack
论坛版主
论坛版主
 
帖子: 12265
注册: 2004-12-16 10:04

Re: 请问怎样实现访客能在商品页面评论、留言?

帖子uhjz » 2008-04-15 17:34

JACK 大哥,非常感谢你耐心的解答。
我想,要是能再加入一个文本框,让客户填写Email,登录后台就知怎样联系客户,那就很完善了。
要是,还能像ask a question模块那样,自动发送一封邮件到店主的邮箱,那就更好了。
请Jack大哥和各位高手看看有没有解决的办法。谢谢大家了。
uhjz
普通会员
普通会员
 
帖子: 43
注册: 2007-10-21 20:25

Re: 请问怎样实现访客能在商品页面评论、留言?

帖子mu2002 » 2008-12-04 1:17

覆盖源文件?跟原文件不知道哪点修改了,我用的模板里没这个文件, 是不是要从默认模板里复制过来,,
mu2002
 
帖子: 3
注册: 2008-11-30 22:23

Re: 请问怎样实现访客能在商品页面评论、留言?

帖子zhjhqk » 2010-12-01 14:53

jack,方法好像不行啊,我把文件都用你说的替换了,可是一点击写留言,它还是让登陆,或者注册啊
zhjhqk
VIP会员
VIP会员
 
帖子: 396
注册: 2010-09-21 10:16

Re: 请问怎样实现访客能在商品页面评论、留言?

帖子Jack » 2010-12-02 3:51

自己检查下修改的文件,我刚在最新版的zencart上测试了可以用
Zen Cart - 让每个人拥有自己生意的梦想成真
加入Zen Cart地图 | 恕不回复站内短信提问 | QQ: 3171061
头像
Jack
论坛版主
论坛版主
 
帖子: 12265
注册: 2004-12-16 10:04

Re: 请问怎样实现访客能在商品页面评论、留言?

帖子zhjhqk » 2010-12-02 11:42

嗯,好的,谢谢!
zhjhqk
VIP会员
VIP会员
 
帖子: 396
注册: 2010-09-21 10:16

下一页

  • 相关话题
    回复总数
    阅读次数
    最新文章

回到 精华共享



在线用户

正在浏览此版面的用户:没有注册用户 和 0 位游客