In this tutorial we are going to learn about Move Product From Wishlist to Cart.
So let see how can we Move Product From Wishlist to Cart.
First of all go to the WishlistController add create a function here


public function moveToCart(Request $request)
{
$item = Cart::instance('wishlist')->get($request->rowId);
Cart::instance('wishlist')->remove($request->rowId);
Cart::instance('cart')->add($item->model->id, $item->model->name, 1, $item->model->regular_price)->associate('App\Models\Product');
return redirect()->route('wishlist.list');
}



Now lets create the route for this function


Route::post('/wishlist/move-to-cart',[WishlistController::class,'moveToCart'])->name('wishlist.move.to.cart');


Now go to the wishlist.blade.php file and a form here


<form id="moveToCart" action="{{route('wishlist.move.to.cart')}}" method="POST">
@csrf
<input type="hidden" name="rowId" id="mrowId" />
</form>


Now create a JavaScript function


@push('scripts')
<script>
function moveToCart(rowId)
{
$("#mrowId").val(rowId);
$("#moveToCart").submit();
}

</script>
@endpush


Now call this moveToCart function from here


<td>
@if($item->model->stock_status == 'instock')
<a href="javascript:void(0)" class="icon" onclick="moveToCart('{{$item->rowId}}')">
<i class="fas fa-shopping-cart"></i>
</a>
@else
<a href="javascript:void(0)" class="icon disabled">
<i class="fas fa-shopping-cart"></i>
</a>
@endif
<a href="javascript:void(0)" class="icon" onclick="removeFromWishlist('{{$item->rowId}}')">
<i class="fas fa-times"></i>
</a>
</td>


Now its done so lets check it
Refresh the page
Now lets move this product to the cart
So click here
And you can see product has been removed from here and
Now lets check the cart
So click here and here you can see the that product
So in this way you can Move Product From Wishlist to Cart.