/** * Find valid row by id+price+options * * @param CartCollection $cart * @param string $id * @param string $price * @param array $options * @return CartRowCollection */ protected function findRowByAttributes($cart, $id, $price, array $options = []) { $row = $cart->where('id', $id); if (!$row->isEmpty()) { $row = $row->where('price', $price); if (!$row->isEmpty()) { $row = $row->whereLoose('options', new CartRowOptionsCollection($options)); if (!$row->isEmpty()) { return $row->first(); } } } return null; }
/** * check if cart is empty * * @return bool */ public function isEmpty() { $cart = new CartCollection($this->session->get($this->sessionKeyCartItems)); return $cart->isEmpty(); }