{"action":"opened","issue":{"url":"https://api.github.com/repos/mike182uk/cart/issues/15","labels_url":"https://api.github.com/repos/mike182uk/cart/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/mike182uk/cart/issues/15/comments","events_url":"https://api.github.com/repos/mike182uk/cart/issues/15/events","html_url":"https://github.com/mike182uk/cart/issues/15","id":107348869,"number":15,"title":"Check if product exist before Item add","user":{"login":"nikmauro","id":1499193,"avatar_url":"https://avatars.githubusercontent.com/u/1499193?v=3","gravatar_id":"","url":"https://api.github.com/users/nikmauro","html_url":"https://github.com/nikmauro","followers_url":"https://api.github.com/users/nikmauro/followers","following_url":"https://api.github.com/users/nikmauro/following{/other_user}","gists_url":"https://api.github.com/users/nikmauro/gists{/gist_id}","starred_url":"https://api.github.com/users/nikmauro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikmauro/subscriptions","organizations_url":"https://api.github.com/users/nikmauro/orgs","repos_url":"https://api.github.com/users/nikmauro/repos","events_url":"https://api.github.com/users/nikmauro/events{/privacy}","received_events_url":"https://api.github.com/users/nikmauro/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-19T18:23:11Z","updated_at":"2015-09-19T18:23:11Z","closed_at":null,"body":"How it possible to check if the ITEM exist in cart before add this.\r\nThere is a method that return #ID before $cart->add();\r\n\r\n```PHP\r\npublic function add($params=array()){\r\n        $item = new CartItem;\r\n        $item->name = isset($params['name'])?$params['name']:'Test Product';\r\n        $item->sku = $params['sku'];\r\n        $item->price = 100;\r\n        $item->tax = 23;\r\n        $item->quantity = 1;\r\n        $item->options = array(\r\n            'ram' => '8 GB',\r\n            'ssd' => '256 GB'\r\n        );\r\n\r\n       //return the ITEM #ID\r\n       //check if product exist  $cart->has('#ID')\r\n\r\n        $this->cart->add($item);\r\n        $this->save();\r\n    }\r\n```"}}