Cart optimization reverted
This commit is contained in:
parent
0fee916bf9
commit
22f995475d
|
|
@ -367,8 +367,6 @@ class CartRule
|
|||
|
||||
$cart->save();
|
||||
|
||||
Cart::setCart($cart);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -432,8 +430,6 @@ class CartRule
|
|||
$cart->applied_cart_rule_ids = join(',', $cartAppliedCartRuleIds);
|
||||
|
||||
$cart->save();
|
||||
|
||||
Cart::setCart($cart);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ class Cart
|
|||
{
|
||||
}
|
||||
|
||||
protected $cart;
|
||||
/**
|
||||
* Returns cart.
|
||||
*
|
||||
|
|
@ -57,31 +56,20 @@ class Cart
|
|||
*/
|
||||
public function getCart(): ?\Webkul\Checkout\Contracts\Cart
|
||||
{
|
||||
if ($this->cart) {
|
||||
return $this->cart;
|
||||
}
|
||||
$cart = null;
|
||||
|
||||
if (auth()->guard()->check()) {
|
||||
$this->cart = $this->cartRepository->findOneWhere([
|
||||
$cart = $this->cartRepository->findOneWhere([
|
||||
'customer_id' => auth()->guard()->user()->id,
|
||||
'is_active' => 1,
|
||||
]);
|
||||
} else if (session()->has('cart')) {
|
||||
$this->cart = $this->cartRepository->find(session()->get('cart')->id);
|
||||
$cart = $this->cartRepository->find(session()->get('cart')->id);
|
||||
}
|
||||
|
||||
$this->removeInactiveItems($this->cart);
|
||||
$this->removeInactiveItems($cart);
|
||||
|
||||
return $this->cart;
|
||||
}
|
||||
/**
|
||||
* Returns cart.
|
||||
*
|
||||
* @return \Webkul\Checkout\Contracts\Cart|null
|
||||
*/
|
||||
public function setCart($cart)
|
||||
{
|
||||
$this->cart = $cart;
|
||||
return $cart;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -170,8 +158,6 @@ class Cart
|
|||
}
|
||||
}
|
||||
|
||||
$this->setCart($cart);
|
||||
|
||||
Event::dispatch('checkout.cart.add.after', $cart);
|
||||
|
||||
$this->collectTotals();
|
||||
|
|
@ -294,8 +280,6 @@ class Cart
|
|||
if (session()->has('cart')) {
|
||||
session()->forget('cart');
|
||||
}
|
||||
|
||||
$this->setCart(null);
|
||||
}
|
||||
|
||||
Shipping::collectRates();
|
||||
|
|
@ -329,9 +313,7 @@ class Cart
|
|||
$this->removeItem($item->id);
|
||||
}
|
||||
|
||||
$this->setCart(null);
|
||||
|
||||
Event::dispatch('checkout.cart.delete.all.after', null);
|
||||
Event::dispatch('checkout.cart.delete.all.after', $cart);
|
||||
|
||||
return $cart;
|
||||
}
|
||||
|
|
@ -359,8 +341,6 @@ class Cart
|
|||
if (session()->has('cart')) {
|
||||
session()->forget('cart');
|
||||
}
|
||||
|
||||
$this->setCart(null);
|
||||
}
|
||||
|
||||
session()->flash('info', __('shop::app.checkout.cart.item.inactive'));
|
||||
|
|
@ -397,8 +377,6 @@ class Cart
|
|||
|
||||
$cart->save();
|
||||
|
||||
$this->setCart($cart);
|
||||
|
||||
$this->collectTotals();
|
||||
|
||||
return true;
|
||||
|
|
@ -423,8 +401,6 @@ class Cart
|
|||
$cart->shipping_method = $shippingMethodCode;
|
||||
$cart->save();
|
||||
|
||||
$this->setCart($cart);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -516,8 +492,6 @@ class Cart
|
|||
|
||||
$cart->save();
|
||||
|
||||
$this->setCart($cart);
|
||||
|
||||
Event::dispatch('checkout.cart.collect.totals.after', $cart);
|
||||
}
|
||||
|
||||
|
|
@ -569,8 +543,6 @@ class Cart
|
|||
$item->save();
|
||||
}
|
||||
|
||||
$this->setCart($cart);
|
||||
|
||||
Event::dispatch('checkout.cart.calculate.items.tax.after', $cart);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,6 @@ class CheckoutServiceProvider extends ServiceProvider
|
|||
return new Cart();
|
||||
});
|
||||
|
||||
$this->app->singleton('cart', \Webkul\Checkout\Cart::class);
|
||||
$this->app->bind('cart', \Webkul\Checkout\Cart::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@ trait CartCoupons
|
|||
|
||||
$cart->save();
|
||||
|
||||
$this->setCart($cart);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -43,8 +41,6 @@ trait CartCoupons
|
|||
|
||||
$cart->save();
|
||||
|
||||
$this->setCart($cart);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
@ -68,8 +68,6 @@ trait CartTools
|
|||
|
||||
$this->cartRepository->delete($guestCart->id);
|
||||
|
||||
$this->setCart($cart);
|
||||
|
||||
session()->forget('cart');
|
||||
}
|
||||
}
|
||||
|
|
@ -241,8 +239,6 @@ trait CartTools
|
|||
|
||||
if (! $cart->items->count()) {
|
||||
$this->cartRepository->delete($cart->id);
|
||||
|
||||
$this->setCart(null);
|
||||
}
|
||||
|
||||
$this->collectTotals();
|
||||
|
|
|
|||
Loading…
Reference in New Issue