我正在使用Magento,我想完成以下任务:
客户可以写评论我的产品.他们可以评价价格,质量等几种选择.
当他们评价产品时,评论和评级显示在产品页面上.对于每个费率选项,我看到评级的星级,但我想要的是该客户的评级的总和.
因此,此总评级必须与产品列表中的总评级相同.
我希望有人可以帮助我.
提前致谢!
在*magento/app/design/frontend/base/[your_theme] /template/review/product/view/list.phtml*
您将看到以下foreach循环:
<?php foreach ($_votes as $_vote): ?>
<tr>
<th><?php echo $this->escapeHtml($_vote->getRatingCode()) ?></th>
<td>
<div class="rating-box">
<div class="rating" style="width:<?php echo $_vote->getPercent() ?>%;"></div>
</div>
</td>
</tr>
<?php endforeach; ?>
Run Code Online (Sandbox Code Playgroud)
这会循环每次投票并将其作为星级评分输出.
将其更改为以下内容:
<?php
$_percent = 0;
foreach ($_votes as $_vote) {
$_percent = $_percent + $_vote->getPercent();
}
$_percent = $_percent / count($_votes);
?>
<tr>
<th>Aggregate rating:</th>
<td>
<div class="rating-box">
<div class="rating" style="width:<?php echo $_percent ?>%;"></div>
</div>
</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
您现在不是显示每个投票,而是计算汇总百分比,而只输出一票.
| 归档时间: |
|
| 查看次数: |
5103 次 |
| 最近记录: |