Skip to content
Advertisement

How can I display my products from the cart?

I am using Melihovv ShoppingCart. I want to display all products inside cart but I couldn’t. It shows the page but the products are not displaying.

Here is my code

public function store(Request $request)
{
   
    $cartItem = Cart::add($request->id, $request->name, $request->price, 1);
    return view('pages.cart')->with([
        'cartItem' => $request->cartItem
    ]);
    
}

And here is my view:

@if (!empty($cartItem) && count($cartItem) > 0)
    @foreach ($cartItem as $product)
        {{ $product }}
    @endforeach
@endif

Advertisement

Answer

to display the content of the cart, I think you should use

Cart::content()
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement