From be2b55a8988ab1556b6182cdffdcbf1d27c28a68 Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Sat, 29 Jun 2019 18:44:23 +0530 Subject: [PATCH 1/2] fixed event fire on movetocart from wishlist --- packages/Webkul/Checkout/src/Cart.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index bc0364ce7..523ec26c5 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -1124,7 +1124,7 @@ class Cart { $data['quantity'] = 1; $data['product'] = $product->id; - \Event::fire('checkout.cart.add.after', $product->id); + \Event::fire('checkout.cart.add.before', $product->id); $result = $this->add($product->id, $data); From e0bbae7f8a26ed979883d13f280094427a817f9d Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Sat, 29 Jun 2019 18:47:22 +0530 Subject: [PATCH 2/2] 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