@php
$existing = isset($order) ? $order->cart->cartProducts : collect();
$oldProducts = collect(old('products', []));
$productIndex = 0;
@endphp
@if ($oldProducts->count())
@foreach ($oldProducts as $i => $p)
@php $productIndex++; @endphp
@endforeach
@elseif (isset($order) && $existing->count())
@foreach ($existing as $i => $cartProduct)
@php $productIndex++; @endphp
@endforeach
@else
@php $productIndex++; @endphp
@endif