In this video we are going to learn about Delete Product from Cart.
So let see how can we delete product from the cart.
For deleting cart product lets create a function inside the app/http/livewire/CartComponent.php class file
inside this file lets create a function for delete product from cart by rowId.

public function destroy($rowId)
session()->flash('success_message','Item has been removed');

Now open CartComponent View File and
And lets call the destroy function on click event

<div class=\"delete\">
<a href=\"#\" wire:click.prevent=\"destroy('{{$item->rowId}}')\" class=\"btn btn-delete\" title=\"\">
<span>Delete from your cart</span>
<i class=\"fa fa-times-circle\" aria-hidden=\"true\"></i>

Now lets check this.
So switch to the browser and lets add some product.
Now for removing the product from cart lets click on this delete icon.
And you can see here item has been removed.
Now lets remove another one, you can see product has been removed.
Now lets create function for empty all product form the cart.
For that go to the CartComponent.php class file.
And inside this file lets create another function

public function destroyAll()
session()->flash('success_message','All Item are removed');

Now open cart-component.blade.php view file and here inside this link.
Simply call the function on click event.

<div class=\"update-clear\">
<a class=\"btn btn-clear\" href=\"#\" wire:click.prevent=\"destroyAll()\">Clear Shopping Cart</a>
<a class=\"btn btn-update\" href=\"#\">Update Shopping Cart</a>

Now lets check this
So switch to the browser and lets add some product to the cart and now click on Clear Shopping Cart Link.
Now you can see here all products have been removed from cart
So in this way you can remove or empty the cart in laravel 8 ecommerce.