Try catch handler in move to cart from wishlist

This commit is contained in:
Prashant Singh 2019-06-29 18:47:22 +05:30
parent be2b55a898
commit e0bbae7f8a
2 changed files with 9 additions and 3 deletions

View File

@ -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()) {

View File

@ -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.singh852@webkul.com> @prashant-webkul
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class CartController extends Controller