diff --git a/packages/Webkul/Shop/src/Http/Controllers/CartController.php b/packages/Webkul/Shop/src/Http/Controllers/CartController.php index a6ee00c8e..a996d2fe8 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/CartController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/CartController.php @@ -141,7 +141,7 @@ class CartController extends Controller * Function to move a already added product to wishlist will run only on customer authentication. * * @param int $id - * @return \Illuminate\Http\Response + * @return mixed */ public function moveToWishlist($id) { @@ -153,7 +153,9 @@ class CartController extends Controller session()->flash('warning', trans('shop::app.checkout.cart.move-to-wishlist-error')); } - return redirect()->back(); + return request()->get('redirect') !== false + ? redirect()->back() + : response()->json([]); } /** diff --git a/packages/Webkul/Shop/src/Http/routes.php b/packages/Webkul/Shop/src/Http/routes.php index fbc4e515c..6486fb236 100755 --- a/packages/Webkul/Shop/src/Http/routes.php +++ b/packages/Webkul/Shop/src/Http/routes.php @@ -88,7 +88,7 @@ Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function ])->name('shop.checkout.success'); //Shop buynow button action - Route::get('move/wishlist/{id}', 'Webkul\Shop\Http\Controllers\CartController@moveToWishlist')->name('shop.movetowishlist'); + Route::post('move/wishlist/{id}', 'Webkul\Shop\Http\Controllers\CartController@moveToWishlist')->name('shop.movetowishlist'); Route::get('/downloadable/download-sample/{type}/{id}', 'Webkul\Shop\Http\Controllers\ProductController@downloadSample')->name('shop.downloadable.download_sample'); diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/cart/index.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/cart/index.blade.php index 6d7ebafb6..9adf18944 100755 --- a/packages/Webkul/Shop/src/Resources/views/checkout/cart/index.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/checkout/cart/index.blade.php @@ -93,9 +93,17 @@ @if ($showWishlist) @if ($item->parent_id != 'null' ||$item->parent_id != null) - {{ __('shop::app.checkout.cart.move-to-wishlist') }} + + {{ __('shop::app.checkout.cart.move-to-wishlist') }} + @else - {{ __('shop::app.checkout.cart.move-to-wishlist') }} + + {{ __('shop::app.checkout.cart.move-to-wishlist') }} + @endif @endif @@ -249,8 +257,22 @@ }); function removeLink(message) { - if (!confirm(message)) - event.preventDefault(); + if (! confirm(message)) { + event.preventDefault(); + return; + } + } + + function moveToWishlist(message, route) { + if (! confirm(message)) { + event.preventDefault(); + return; + } + + axios.post(route, {'redirect': false}) + .then((response) => { + location.reload(); + }); } function updateCartQunatity(operation, index) { diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/customers/account/wishlist/wishlist.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/customers/account/wishlist/wishlist.blade.php index 3149aefdd..5c00a8e2f 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/customers/account/wishlist/wishlist.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/customers/account/wishlist/wishlist.blade.php @@ -12,7 +12,7 @@ @if (count($items))