From e0bbae7f8a26ed979883d13f280094427a817f9d Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Sat, 29 Jun 2019 18:47:22 +0530 Subject: [PATCH] Try catch handler in move to cart from wishlist --- .../src/Http/Controllers/WishlistController.php | 10 ++++++++-- .../Shop/src/Http/Controllers/CartController.php | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php b/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php index 9911b58e7..8979bec31 100755 --- a/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php @@ -134,10 +134,16 @@ class WishlistController extends Controller if(!isset($wishlistItem) || $wishlistItem->customer_id != auth()->guard('customer')->user()->id) { session()->flash('warning', trans('shop::app.security-warning')); - return redirect()->route( 'customer.wishlist.index'); + return redirect()->route('customer.wishlist.index'); } - $result = Cart::moveToCart($wishlistItem); + try { + $result = Cart::moveToCart($wishlistItem); + } catch (\Exception $e) { + session()->flash('warning', $e->getMessage()); + + return redirect()->back(); + } if ($result == 1) { if ($wishlistItem->delete()) { diff --git a/packages/Webkul/Shop/src/Http/Controllers/CartController.php b/packages/Webkul/Shop/src/Http/Controllers/CartController.php index e24d8058b..5db290c6d 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/CartController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/CartController.php @@ -16,7 +16,7 @@ use Cart; * Cart controller for the customer and guest users for adding and * removing the products in the cart. * - * @author Prashant Singh @prashant-webkul + * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class CartController extends Controller