product_item.php 4.89 KB
<?php
    /** @var \common\modules\product\models\Product $product */
    use kartik\rating\StarRating;
    use yii\helpers\Html;
    use yii\helpers\Url;

?>
<li class="item" itemscope itemtype="http://schema.org/Product">
    <div class="boxitem">
        <div class="pixbox">
            <a href="<?= Url::to([
                'catalog/product',
                'product' => $product,
                '#'       => 'm' . $product->enabledVariants[ 0 ]->product_variant_id,
            ]) ?>">
                <?= \common\components\artboximage\ArtboxImageHelper::getImage($product->enabledVariants[ 0 ]->imageUrl, 'list', [
                    'alt'   => $product->category->categoryName->value . ' ' . $product->fullname,
                    'title' => $product->category->categoryName->value . ' ' . $product->fullname,
                ]) ?>
            </a>
        </div>
        <?php if(!empty( $product->is_top ) || !empty( $product->is_new ) || !empty( $product->akciya )) : ?>
            <ul class="product-special">
                <?php if(!empty( $product->is_top )) : ?>
                    <li class="top">
                        <div>top</div>
                    </li>
                <?php endif ?>
                <?php if(!empty( $product->is_new )) : ?>
                    <li class="new">
                        <div>new</div>
                    </li>
                <?php endif ?>
                <?php if(!empty( $product->akciya )) : ?>
                    <li class="promo">
                        <div>promo</div>
                    </li>
                <?php endif ?>
            </ul>
        <?php endif ?>
        <div class="comment_display_block">
            <?php
                if(!empty( $product->averageRating )) {
                    echo StarRating::widget([
                        'name'          => 'rating_product',
                        'value'         => $product->averageRating->value,
                        'pluginOptions' => [
                            'displayOnly' => true,
                            'size'        => 'xxs',
                            'min'         => 0,
                            'max'         => 5,
                            'stars'       => 5,
                        ],
                    ]);
                }
                ?>
                <p>
                    <?php
                        $comment_count = count($product->comments);
                        echo Html::a(($comment_count?'Отзывов: ' . count($product->comments):"Оставить отзыв"), ['catalog/product', 'product' => $product, '#' => 'artbox-comment'])
                    ?>
                </p>
        </div>
        <div itemprop="name"><a href="<?= Url::to([
                'catalog/product',
                'product' => $product,
                '#'       => 'm' . $product->enabledVariants[ 0 ]->product_variant_id,
            ]) ?>"
                class="name"><?= $product->fullname ?>
            </a></div>
        
        <?php
            
            echo '<div class="cost-block" itemprop="offers" itemscope itemtype="http://schema.org/Offer">';
            echo '<p class="cost">';
            // есть скидка
            if($product->enabledVariants[ 0 ]->price_old != 0 && $product->enabledVariants[ 0 ]->price_old != $product->enabledVariants[ 0 ]->price) {
                echo '<strike><span id=\'old_cost\' itemprop="price">' . $product->enabledVariants[ 0 ]->price_old . '</span> грн.</strike>&nbsp;';
            }
            
            echo $product->enabledVariants[ 0 ]->price . ' <span>грн.</span></p>';
            echo '<meta itemprop="priceCurrency" content = "UAH">';
            echo '</div>';
        
        ?>
    </div>
    <a href="<?= Url::to([
        'catalog/product',
        'product' => $product,
        '#'       => 'm' . $product->enabledVariants[ 0 ]->product_variant_id,
    ]) ?>" class="link_buy">Купить</a>
    
    <div class="mycarousel">
        <ul class="jcarousel jcarousel-skin-tango">
            <?php foreach($product->enabledVariants as $variant) : ?>
                <?php if(!empty( $variant->image )) : ?>
                    <li>
                        <a href="<?= Url::to([
                            'catalog/product',
                            'product' => $product,
                            '#'       => 'm' . $variant->product_variant_id,
                        ]) ?>">
                            <?= \common\components\artboximage\ArtboxImageHelper::getImage($variant->imageUrl, 'product_variant', [
                                'alt'   => $product->category->categoryName->value . ' ' . $product->fullname,
                                'title' => $product->category->categoryName->value . ' ' . $product->fullname,
                            ]) ?>
                        </a>
                    </li>
                <?php endif; ?>
            <?php endforeach; ?>
        </ul>
    </div>
</li>