summary.phtml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. // @codingStandardsIgnoreFile
  7. /** @var \Magento\Review\Block\Product\ReviewRenderer $block */
  8. $url = $block->getReviewsUrl() . '#reviews';
  9. $urlForm = $block->getReviewsUrl() . '#review-form';
  10. ?>
  11. <?php if ($block->isReviewEnabled() && $block->getReviewsCount()): ?>
  12. <?php $rating = $block->getRatingSummary(); ?>
  13. <div class="product-reviews-summary<?= !$rating ? ' no-rating' : '' ?>" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
  14. <?php if ($rating):?>
  15. <div class="rating-summary">
  16. <span class="label"><span><?= $block->escapeHtml(__('Rating')) ?>:</span></span>
  17. <div class="rating-result" title="<?= $block->escapeHtmlAttr($rating); ?>%">
  18. <span style="width:<?= $block->escapeHtmlAttr($rating); ?>%">
  19. <span>
  20. <span itemprop="ratingValue"><?= $block->escapeHtml($rating); ?></span>% of <span itemprop="bestRating">100</span>
  21. </span>
  22. </span>
  23. </div>
  24. </div>
  25. <?php endif;?>
  26. <div class="reviews-actions">
  27. <a class="action view"
  28. href="<?= $block->escapeUrl($url) ?>">
  29. <span itemprop="reviewCount"><?= $block->escapeHtml($block->getReviewsCount()) ?></span>&nbsp;
  30. <span><?= ($block->getReviewsCount() == 1) ? $block->escapeHtml(__('Review')) : $block->escapeHtml(__('Reviews')) ?></span>
  31. </a>
  32. <a class="action add" href="<?= $block->escapeUrl($urlForm) ?>"><?= $block->escapeHtml(__('Add Your Review')) ?></a>
  33. </div>
  34. </div>
  35. <?php elseif ($block->isReviewEnabled() && $block->getDisplayIfEmpty()): ?>
  36. <div class="product-reviews-summary empty">
  37. <div class="reviews-actions">
  38. <a class="action add" href="<?= $block->escapeUrl($urlForm) ?>">
  39. <?= $block->escapeHtml(__('Be the first to review this product')) ?>
  40. </a>
  41. </div>
  42. </div>
  43. <?php endif; ?>