/** * Looks through cart items and checks the posts are not trashed or deleted. * * @return bool|Notifier */ public function checkCartItemValidity() { $return = true; foreach ($this->getCart() as $cart_item_key => $cartitem) { $product = $cartitem->get('product'); if (!$product || !$product->exists() || 'trash' === $product->getStatus()) { $this->setQuantity($cart_item_key, 0); $return = Notifier::notify('An item which is no longer available was removed from your cart.'); } } return $return; }