From 28af2908cd5d62a4c529fc9875ed4e03f7137564 Mon Sep 17 00:00:00 2001 From: devansh bawari Date: Fri, 6 Aug 2021 23:25:27 +0530 Subject: [PATCH] Display None Added To Form --- .../src/Http/Controllers/CartController.php | 6 ++-- packages/Webkul/Shop/src/Http/routes.php | 2 +- .../views/checkout/cart/index.blade.php | 30 ++++++++++++++++--- .../account/wishlist/wishlist.blade.php | 2 +- .../views/shop/products/wishlist.blade.php | 18 +++++++++-- 5 files changed, 47 insertions(+), 11 deletions(-) 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))
-
+ @method('DELETE') @csrf diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/products/wishlist.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/products/wishlist.blade.php index 80a143abc..17f0cddf9 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/products/wishlist.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/products/wishlist.blade.php @@ -15,13 +15,21 @@ @endphp @if($wishlist) - + @method('DELETE') @csrf
@else -
+ @csrf
@endif @@ -41,7 +49,11 @@ @endauth @guest('customer') -
+ @csrf