@php use Botble\Ecommerce\Models\SpecificationTable; $version = EcommerceHelper::getAssetVersion(); Theme::asset()->add('front-ecommerce-css', 'vendor/core/plugins/ecommerce/css/front-ecommerce.css', version: $version); Theme::asset()->add('front-compare-css', 'vendor/core/plugins/ecommerce/css/front-compare.css', version: $version); Theme::asset()->container('footer')->add('front-compare-js', 'vendor/core/plugins/ecommerce/js/front-compare.js', ['jquery'], version: $version); $hasProducts = $products->isNotEmpty(); $hasSpecGroups = ($specGroups ?? collect())->isNotEmpty(); $hasAttributeSets = $attributeSets->isNotEmpty(); $maxProducts = $maxProducts ?? 4; $emptySlots = max(0, $maxProducts - $products->count()); $shareUrl = $shareUrl ?? route('public.compare'); @endphp
@if ($hasProducts)

{{ trans('plugins/ecommerce::products.compare.heading') }} @if ($products->count() >= 2) {{ $products->pluck('name')->implode(' ' . trans('plugins/ecommerce::products.compare.vs_separator') . ' ') }} @endif

{{ trans('plugins/ecommerce::products.compare.slot_count', ['count' => $products->count(), 'max' => $maxProducts]) }}
@if ($hasSpecGroups || $hasAttributeSets) @endif @if ($products->count() >= 2) @endif
@foreach ($products as $product) @endforeach @for ($i = 0; $i < $emptySlots; $i++) @endfor @foreach ($products as $product) @endforeach @for ($i = 0; $i < $emptySlots; $i++) @endfor @if ($hasSpecGroups) @foreach ($specGroups as $group) @foreach ($group['attributes'] as $attribute) @foreach ($products as $product) @php $data = SpecificationTable::getAttributeDisplayData($product, $attribute); $value = trim((string) ($data['displayValue'] ?? '')); @endphp @endforeach @for ($i = 0; $i < $emptySlots; $i++) @endfor @endforeach @endforeach @endif @if ($hasAttributeSets) @foreach ($attributeSets as $attributeSet) @foreach ($products as $product) @php $rendered = trim((string) render_product_attributes_view_only($product, $attributeSet)); @endphp @endforeach @for ($i = 0; $i < $emptySlots; $i++) @endfor @endforeach @endif @foreach ($products as $product) @endforeach @for ($i = 0; $i < $emptySlots; $i++) @endfor @if (EcommerceHelper::isReviewEnabled()) @foreach ($products as $product) @endforeach @for ($i = 0; $i < $emptySlots; $i++) @endfor @endif

{{ $product->name }}

@include(EcommerceHelper::viewPath('includes.product-price'), [ 'priceWrapperClassName' => 'compare-price', 'priceClassName' => '', 'priceOriginalWrapperClassName' => '', 'priceOriginalClassName' => 'old-price', ])
@php $savingsPercent = $product->price > 0 && $product->front_sale_price < $product->price ? (int) round((($product->price - $product->front_sale_price) / $product->price) * 100) : 0; @endphp @if ($savingsPercent >= 1)
{{ trans('plugins/ecommerce::products.compare.savings_off', ['percent' => $savingsPercent]) }}
@endif
$product->isOutOfStock(), 'compare-stock-in' => ! $product->isOutOfStock()])> @if ($product->isOutOfStock()) {{ trans('plugins/ecommerce::ecommerce.out_of_stock') }} @else {{ trans('plugins/ecommerce::ecommerce.in_stock') }} @endif
@include(EcommerceHelper::viewPath('includes.compare-add-slot'))
{{ $group['group']->name }}
{{ $attribute->name }} @if ($value !== '') {!! BaseHelper::clean($value) !!} @else — @endif —
{{ trans('plugins/ecommerce::products.compare.additional_attributes') }}
{{ $attributeSet->title }} @if ($rendered !== '') {!! $rendered !!} @else — @endif —
{{ trans('plugins/ecommerce::products.sku') }}{{ $product->sku ? '#' . $product->sku : '—' }}—
{{ trans('plugins/ecommerce::review.rating') }} @if (! EcommerceHelper::hideRatingWhenNoReviews() || $product->reviews_count > 0)
@include(EcommerceHelper::viewPath('includes.rating-star'), ['avg' => $product->reviews_avg, 'size' => 80])
@else — @endif
—
@else @include(EcommerceHelper::viewPath('includes.empty-state'), [ 'icon' => 'ti ti-arrows-left-right', 'title' => trans('plugins/ecommerce::ecommerce.your_compare_list_is_empty'), 'description' => trans('plugins/ecommerce::products.compare.empty_description'), 'label' => trans('plugins/ecommerce::products.compare.browse_products'), ]) @endif @if ($hasProducts && $emptySlots > 0) @include(EcommerceHelper::viewPath('includes.compare-picker-modal')) @endif