In this video we are going to learn about Update Cart Quantity
So let see how can we update quantity in cart.
For increasing and decreasing the product quantity
lets create two functions inside the cart component class file one for the increase the product quantity and another for decreasing the product quantity.
Switch to the project and just go inside the app\\http\\livewire and then open CartComponent.php file


public function increaseQuantity($rowId)
{
$product = Cart::instance('cart')->get($rowId);
$qty = $product->qty + 1;
Cart::instance('cart')->update($rowId,$qty);
}

public function decreaseQuantity($rowId)
{
$product = Cart::instance('cart')->get($rowId);
$qty = $product->qty - 1;
Cart::instance('cart')->update($rowId,$qty);
}


Inside this file lets create the functions Now lets call this function on click event of this + and –
For that just go the Cart-Component view file and
Inside the increase link add here increaseQuantity and inside this function just pass the rowId.
And inside this reduce link add here decreaseQuantity and inside this function just pass the rowId.


<div class=\"quantity-input\">
<input type=\"text\" name=\"product-quatity\" value=\"{{$item->qty}}\" data-max=\"120\" pattern=\"[0-9]*\" >
<a class=\"btn btn-increase\" href=\"#\" wire:click.prevent=\"increaseQuantity('{{$item->rowId}}')\"></a>
<a class=\"btn btn-reduce\" href=\"#\" wire:click.prevent=\"decreaseQuantity('{{$item->rowId}}')\"></a>
</div>


Now its done so lets check this
So first of all lets add product to the cart
Now click on + icon for increasing one product
So just click here
You can see here no of product has been increased by one
And also increased the subtotal and total price
Now lets decrease the product quantity
So, for that just click on – icon Here you can see her no of product item has been reduced
If I click one more time on this – icon
Then item has been removed from the cart
So in this way you can update the cart quantity in laravel 8 ecommerce project.