@inject ('reviewHelper', 'Webkul\Product\Helpers\Review')
@inject ('wishListHelper', 'Webkul\Customer\Helpers\Wishlist')
@php
    $totalReviews = $reviewHelper->getTotalReviews($product);
    $avgRatings = ceil($reviewHelper->getAverageRating($product));
    $productBaseImage = productimage()->getProductBaseImage($product);
    $discount = discount_prosent($product);
@endphp

        <div class="item-gallery-block">
            @if (! $product->getTypeInstance()->haveSpecialPrice() && $product->new)
                <span class="item-gallery-head">{{ __('shop::app.products.new') }}</span>
            @endif

                <form class="wishlist-{{ $product->product_id }}" action="{{ route('customer.wishlist.add', $product->product_id) }}" method="POST"
                    style="visibility: hidden; height: 0; width: 0;">
                    @csrf
                </form>
                <button type="button" class="item-gallery-fav"
                    @guest('customer')
                        onclick="document.querySelector('.logged-false').click(); return false;"
                    @else
                        onclick="document.querySelector('.wishlist-{{ $product->product_id }}').submit();"
                    @endguest
                >
                    <div>
                        <img src="{{bagisto_asset($wishListHelper->getWishlistProduct($product) ? 'icons/heart.svg' : 'icons/love.svg')}}" alt="fav">
                    </div>
                </button>
            @if($discount)
                <div class="item-gallery-discount">
                    <div class="item-gallery-discount-img">
                        <img src="{{bagisto_asset ('icons/BG.svg') }}" alt="" />
                    </div>
                    <span class="item-gallery-discount-text">{{$discount}}%</span>
                </div>
            @endif

            <div class="item-gallery-img">
                <a href="{{ route('shop.productOrCategory.index', $product->url_key) }}" title="{{ $product->name }}" style="color: black;">
                    <img src="{{ $productBaseImage['medium_image_url'] }}" onerror="this.src='{{ asset('vendor/webkul/ui/assets/images/product/meduim-product-placeholder.png') }}'"
                         alt="{{$product->name}}" />
                </a>
            </div>
            <div class="item-gallery-block-bottom">
                <a href="{{ route('shop.productOrCategory.index', $product->url_key) }}" title="{{ $product->name }}" style="color: black;">
                    <h3 class="item-gallery-name">
                        {{$product->name}}
                    </h3>
                </a>
{{--                <div class="item-gallery-rating">--}}
{{--                    <div class="item-gallery-rating-img">--}}
{{--                        <img src="{{ bagisto_asset('icons/icon (star).svg') }}" alt="star" />--}}
{{--                    </div>--}}
{{--                    <span class="item-gallery-rating-text">{{$avgRatings}}</span>--}}
{{--                    <span class="item-gallery-rating-feed">{{__('shop::app.products.total-reviews',['total'=>$totalReviews])}}</span>--}}
{{--                </div>--}}

                <div class="item-gallery-price">
                    {!! priceHtml($product) !!}
                </div>
                @include('shop::products.add-buttons', ['product' => $product])
            </div>
        </div>
