Merge pull request #1669 from rumansaleem/fix-remove-from-wishlist
Remove item from wishlist, when added to Cart - fixes #1662
This commit is contained in:
commit
752b20d68b
|
|
@ -7,6 +7,7 @@ use Webkul\Checkout\Repositories\CartRepository;
|
|||
use Webkul\Checkout\Repositories\CartItemRepository;
|
||||
use Webkul\API\Http\Resources\Checkout\Cart as CartResource;
|
||||
use Cart;
|
||||
use Webkul\Customer\Repositories\WishlistRepository;
|
||||
|
||||
/**
|
||||
* Cart controller
|
||||
|
|
@ -37,15 +38,24 @@ class CartController extends Controller
|
|||
*/
|
||||
protected $cartItemRepository;
|
||||
|
||||
/**
|
||||
* WishlistRepository object
|
||||
*
|
||||
* @var Object
|
||||
*/
|
||||
protected $wishlistRepository;
|
||||
|
||||
/**
|
||||
* Controller instance
|
||||
*
|
||||
* @param Webkul\Checkout\Repositories\CartRepository $cartRepository
|
||||
* @param Webkul\Checkout\Repositories\CartItemRepository $cartItemRepository
|
||||
* @param Webkul\Checkout\Repositories\WishlistRepository $wishlistRepository
|
||||
*/
|
||||
public function __construct(
|
||||
CartRepository $cartRepository,
|
||||
CartItemRepository $cartItemRepository
|
||||
CartItemRepository $cartItemRepository,
|
||||
WishlistRepository $wishlistRepository
|
||||
)
|
||||
{
|
||||
$this->guard = request()->has('token') ? 'api' : 'customer';
|
||||
|
|
@ -59,6 +69,8 @@ class CartController extends Controller
|
|||
$this->cartRepository = $cartRepository;
|
||||
|
||||
$this->cartItemRepository = $cartItemRepository;
|
||||
|
||||
$this->wishlistRepository = $wishlistRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -97,6 +109,8 @@ class CartController extends Controller
|
|||
], 400);
|
||||
}
|
||||
|
||||
$this->wishlistRepository->deleteWhere(['product_id' => $id]);
|
||||
|
||||
Event::fire('checkout.cart.item.add.after', $result);
|
||||
|
||||
Cart::collectTotals();
|
||||
|
|
|
|||
Loading…
Reference in New Issue