@extends('frontend.layout.app') @section('content')

{{ $categories->heading }}

  • Home
  • {{ $categories->heading }}
@if (session('success')) @endif @if (session('error')) @endif
{{-- Per Page Select, preserve filters --}}
{{-- Preserve filter query params --}} @foreach (request()->except(['per_page', '_token']) as $key => $value) @if (is_array($value)) @foreach ($value as $v) @endforeach @else @endif @endforeach
{{-- Sort By Select, preserve filters --}}
{{-- Preserve filter query params --}} @foreach (request()->except(['sort', '_token']) as $key => $value) @if (is_array($value)) @foreach ($value as $v) @endforeach @else @endif @endforeach
{{-- Product Listing --}} @php // Merge products and vendorProducts collections (if available) $allProducts = collect(); if (isset($products) && $products->count()) { $allProducts = $allProducts->concat($products); } if (isset($vendorProducts) && $vendorProducts->count()) { $allProducts = $allProducts->concat($vendorProducts); } @endphp @if ($allProducts->count() > 0) @foreach ($allProducts as $product) @php $isVendorProduct = $product instanceof \App\Models\VendorProduct; $detailUrl = $isVendorProduct ? route('vendor.productsdetails', $product->id) : route('productsdetails', $product->id); if ($isVendorProduct) { $vendorImage = $product->images->first(); $vendorImagePath = $vendorImage ? $vendorImage->image : null; $productImageUrl = $vendorImagePath ? asset('storage/' . ltrim($vendorImagePath, '/')) : asset('frontend/assets/img/no-image.png'); } else { $productImage = $product->images->first(); $productImageUrl = $productImage ? asset('storage/product/' . $productImage->images) : asset('frontend/assets/img/no-image.png'); } $productName = $product->product_name ?? ''; $productSp = $product->sp ?? 0; $productGst = $product->gst ?? 0; $productMrp = $product->mrp ?? null; // Calculate prices if ($isVendorProduct) { // 1. Calculate with GST $priceWithGst = $productSp + ($productSp * $productGst) / 100; // 2. Calculate Platform Fee (10% of above) $platformFee = $priceWithGst * 0.1; // 3. Total vendor price = priceWithGst + platformFee $vendorTotalPrice = $priceWithGst + $platformFee; } else { $priceWithGst = $productSp + ($productSp * $productGst) / 100; } $reviews = method_exists($product, 'reviews') ? $product->reviews : collect(); $ratings = $reviews->pluck('rating'); $avgRating = $ratings->count() ? round($ratings->avg(), 2) : null; $ratingPercent = $avgRating ? ($avgRating / 5) * 100 : 0; $availableStock = $isVendorProduct ? (int) ($product->stock ?? 0) : (int) ($product->stock ?? 0); @endphp
Image
@if ($isVendorProduct) ₹{{ number_format($vendorTotalPrice, 2) }} @else ₹{{ number_format($priceWithGst, 2) }} @if (!empty($productMrp)) ₹{{ $productMrp }} @endif @endif

{{ ucwords($productName) }}

@auth
@if ($availableStock > 0)
@csrf @if ($isVendorProduct) @else @endif
@else @endif @php $sessionId = session()->getId(); @endphp
@csrf
@endauth
@endforeach @else @if (request('price'))

No products found in this price range

Please try selecting a different price range or remove the price filter.

@endif @endif
@endsection