In this video we are going to learn about move product from wishlist to cart and also Make Quantity working on Product Details Page.
So let see how can we add product to cart from wishlist first.
Switch to the project and lets open the WishlistComponent.php Class file.
And here lets create a function for moving product from wishlist to cart.

public function moveProductFromWishlistToCart($rowId)
{
$item = Cart::instance('wishlist')->get($rowId);
Cart::instance('wishlist')->remove($rowId);
Cart::instance('cart')->add($item->id,$item->name,1,$item->price)->associate('App\\Models\\Product');
$this->emitTo('wishlist-count-component','refreshComponent');
$this->emitTo('cart-count-component','refreshComponent');
}


Now go to the wishlist-component.blade.php view file.
From here lets call the moveProductFromWishlistToCart function

<div class=\"product-info\">
<a href=\"{{route('product.details',['slug'=>$item->model->slug])}}\" class=\"product-name\"><span>{{$item->model->name}}</span></a>
<div class=\"wrap-price\"><span class=\"product-price\">${{$item->model->regular_price}}</span></div>
<a href=\"#\" class=\"btn add-to-cart\" wire:click.prevent=\"moveProductFromWishlistToCart('{{$item->rowId}}')\">Move To Cart</a>
<div class=\"product-wish\">
<a href=\"#\" wire:click.prevent=\"removeFromWishlist({{$item->model->id}})\"><i class=\"fa fa-heart fill-heart\"></i></a>
</div>
</div>


Now its done so lets check it.
So switch to project and just refresh the page.
Now lets add product to the wishlist.
Now lets move product to the cart from wishlist.
So click here add to cart.
Here you can see product has been removed from wishlist and added into the cart.

Now lets see how can make quantiy working on this Product details page
For that go the DetailsComponent.php class file and here
Lets create a property and also set the default value 1;


public $qty=1;


Now here lets create two function one for increase the quantity and another for decrease the quantity.


public function increaseQuantity()
{
$this->qty++;
}

public function decreseQuantity()
{
if($this->qty > 1)
{
$this->qty--;
}
}



Now lets open the details-component.blade.php view file and add the following code.

<div class=\"quantity\">
<span>Quantity:</span>
<div class=\"quantity-input\">
<input type=\"text\" name=\"product-quatity\" value=\"1\" data-max=\"120\" pattern=\"[0-9]*\" wire:model=\"qty\" >
<a class=\"btn btn-reduce\" href=\"#\" wire:click.prevent=\"decreseQuantity\"></a>
<a class=\"btn btn-increase\" href=\"#\" wire:click.prevent=\"increaseQuantity\"></a>
</div>
</div>



Now its done so lets check it.
So switch to the browser and refresh the page.
Now click on any product you can see here the details page.
Now increase the product quantity.
And now lets click on add to cart.
And here you can see the selected no of product has been added in to the cart.
There is one problem in cart if product on sale you can see here it showing here the regular price.
So for showing the sale price go to the cart.blade.php file and here lets remove this ->model->regular_price
and simply write here $item->price.
Now lets check the cart page and you can see the its now showing the sale price.
So in this way you can move product from wishlist to cart and make quantity working on product details page.