<?php

/**
 * Olegnax ProductReviewsSummary
 * 
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Olegnax.com license that is
 * available through the world-wide-web at this URL:
 * https://www.olegnax.com/license
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade this extension to newer
 * version in the future.
 *
 * @category    Olegnax
 * @package     Olegnax_ProductReviewsSummary
 * @copyright   Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
 * @license     https://www.olegnax.com/license
 */

$settings = $this->helper('Olegnax\ProductReviewsSummary\Helper\Helper')->getConfig('olegnax_productreviewssummary/general');

$enabled = $settings['rating_overall'];
$button = $settings['write_btn_overall'];
if($enabled) {
?>
<div class="extended-review-summary">
	<div class="ratings-value"><?= number_format($block->getAverageRating(),1) ?></div>
	<div class="ratings-count">
		<span class="label"><?= $block->getReviewCount() ?> <?= $block->escapeHtml(__('Reviews')) ?></span>
		<?php $block->getRatingVotes(); ?>
		<div class="rating-result" title="<?= $block->escapeHtmlAttr($block->getPercent()) ?>%">
			<meta itemprop="worstRating" content="1">
			<meta itemprop="bestRating" content="100">
			<span style="width:<?= $block->escapeHtmlAttr($block->getPercent()) ?>%">
				<span itemprop="ratingValue"><?= $block->escapeHtmlAttr($block->getPercent()) ?>%</span>
			</span>
		</div>
		<?php if( $button ){ ?>
		<a href="#review-form" class="action write-review"><?= $block->escapeHtml(__('Write a Review')) ?></a>
		<?php } ?>
	</div>
</div>
<?php } ?>