add logging to exception thrown in cart
This commit is contained in:
parent
bfeff060c2
commit
449a2e1d47
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Webkul\Checkout;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Webkul\Checkout\Models\Cart as CartModel;
|
||||
use Webkul\Checkout\Models\CartAddress;
|
||||
use Webkul\Checkout\Repositories\CartRepository;
|
||||
|
|
@ -122,9 +124,11 @@ class Cart
|
|||
/**
|
||||
* Add Items in a cart with some cart and item details.
|
||||
*
|
||||
* @param int $productId
|
||||
* @param array $data
|
||||
* @return \Webkul\Checkout\Contracts\Cart|\Exception|array
|
||||
* @param int $productId
|
||||
* @param array $data
|
||||
*
|
||||
* @return \Webkul\Checkout\Contracts\Cart|string|array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addProduct($productId, $data)
|
||||
{
|
||||
|
|
@ -147,7 +151,8 @@ class Cart
|
|||
session()->forget('cart');
|
||||
}
|
||||
|
||||
throw new \Exception($cartProducts);
|
||||
Log::error($cartProducts, ['product' => $product, 'cartData' => $data]);
|
||||
throw new Exception($cartProducts);
|
||||
} else {
|
||||
$parentCartItem = null;
|
||||
|
||||
|
|
@ -161,7 +166,7 @@ class Cart
|
|||
if (! $cartItem) {
|
||||
$cartItem = $this->cartItemRepository->create(array_merge($cartProduct, ['cart_id' => $cart->id]));
|
||||
} else {
|
||||
if (isset($cartProduct['parent_id']) && $cartItem->parent_id != $parentCartItem->id) {
|
||||
if (isset($cartProduct['parent_id']) && $cartItem->parent_id !== $parentCartItem->id) {
|
||||
$cartItem = $this->cartItemRepository->create(array_merge($cartProduct, [
|
||||
'cart_id' => $cart->id
|
||||
]));
|
||||
|
|
@ -232,7 +237,8 @@ class Cart
|
|||
* Update cart items information
|
||||
*
|
||||
* @param array $data
|
||||
* @return bool|void|\Exception
|
||||
*
|
||||
* @return bool|void|Exception
|
||||
*/
|
||||
public function updateItems($data)
|
||||
{
|
||||
|
|
@ -246,13 +252,13 @@ class Cart
|
|||
if ($quantity <= 0) {
|
||||
$this->removeItem($itemId);
|
||||
|
||||
throw new \Exception(trans('shop::app.checkout.cart.quantity.illegal'));
|
||||
throw new Exception(trans('shop::app.checkout.cart.quantity.illegal'));
|
||||
}
|
||||
|
||||
$item->quantity = $quantity;
|
||||
|
||||
if (! $this->isItemHaveQuantity($item)) {
|
||||
throw new \Exception(trans('shop::app.checkout.cart.quantity.inventory_warning'));
|
||||
throw new Exception(trans('shop::app.checkout.cart.quantity.inventory_warning'));
|
||||
}
|
||||
|
||||
Event::dispatch('checkout.cart.update.before', $item);
|
||||
|
|
|
|||
Loading…
Reference in New Issue