@php $items = []; $totalValue = 0; foreach ($cartItems as $row) { $price = $row['discount_price'] ?? $row['price'] ?? 0; $qty = $row['qty'] ?? $row['quantity'] ?? 1; $item = [ 'item_id' => (string) ($row['id'] ?? $row['product_id'] ?? ''), 'item_name' => (string) ($row['name'] ?? $row['product_name'] ?? 'Product'), 'affiliation' => config('app.name', 'MyCommerce'), 'item_brand' => config('app.name', 'MyCommerce'), 'item_category' => (string) ($row['category_name'] ?? ($row['category']->name ?? '')), 'price' => (float) $price, 'quantity' => (int) $qty, ]; $items[] = $item; $totalValue += $price * $qty; } @endphp