@extends('layouts.user') @section('content')

Shopping Cart

@php $grandTotal = 0; @endphp @if($cartItems->count() > 0) @foreach($cartItems as $item) @php // Use price from DB (already saved when variant selected) $price = $item->price; $total = $price * $item->quantity; $grandTotal += $total; $productVariants = $variants->get($item->product_id, collect()); // Merge old variant if missing if(isset($item->product_variant_id) && $item->product_variant_id) { $selectedVariant = \DB::table('product_variants')->where('variant_id', $item->product_variant_id)->first(); if($selectedVariant && !$productVariants->contains('variant_id', $selectedVariant->variant_id)) { $productVariants->push($selectedVariant); } } @endphp @endforeach
Products Price Quantity Total Price
{{ $item->product->product_name }}
{{ $item->product->product_name }}
@if($productVariants->isNotEmpty()) @php $groupedVariants = $productVariants->groupBy('variable_name'); @endphp @foreach($groupedVariants as $variableName => $group) @endforeach @else - @endif
₹{{ number_format($price,2) }}
- +
@else

Your cart is empty. Add products to your cart

@endif
Order Summary
Subtotal ₹{{ number_format($grandTotal,2) }}
@endsection