@php $currencyIcon = \App\Models\Setting::where('key', 'site_currency_icon')->value('value'); @endphp @foreach($cartItems as $cartItem) @php // Check if cartItem is an object (logged-in user) or array (guest user) $isObject = is_object($cartItem); $productId = $isObject ? $cartItem->product_id : $cartItem['product_id']; $variantId = $isObject ? $cartItem->variant_id : $cartItem['variant_id']; $quantity = $isObject ? $cartItem->quantity : $cartItem['quantity']; $cartItemId = $isObject ? $cartItem->id : $loop->index; // Get product details $product = \App\Models\Product::find($productId); $price = $product ? $product->getVariantOrProductPriceAndStock($variantId) : null; $productName = $isObject ? $cartItem->product?->name : $cartItem['name']; $productImage = $isObject ? asset($cartItem->product?->primaryImage?->path) : $cartItem['image']; $variantName = $isObject ? ($cartItem->product?->variants()->where('id', $variantId)->first()->name ?? '') : ''; @endphp #
{{ $productName }}
{{ $variantName }}
(4.0)
@if($price && $price['in_stock']) @if ($price['old_price'])

{{ $currencyIcon }}{{ $price['price'] }}

$ {{ $price['old_price'] }}

@else

{{ $currencyIcon }}{{ $price['price'] }}

@endif

{{ $currencyIcon }}{{ $price['price'] * $quantity }}

@else

Out of stock

@endif
@csrf @method('DELETE')
@endforeach