title: Codeigniter cart
body: <p>I am new and I don't know much.
  I tried several ways but still nothing.
  It's not working this way.</p>
  
  <pre><code>public function addToCart(){
      $product_url=md5($this-&gt;input-&gt;post('produktUrl'));
      $cart['id']=$product_url;
      $cart['qty']=$this-&gt;input-&gt;post('kol');
      $cart['price']=$this-&gt;model-&gt;cena($this-&gt;input-&gt;post('produktUrl'));
      $cart['name']=$this-&gt;input-&gt;post('produktUrl');
      $cart['ime']=$this-&gt;input-&gt;post('ime');
  
      $cart['options']['size']=$this-&gt;input-&gt;post('golemina');
      $cart['options']['color']=$this-&gt;input-&gt;post('boja');
  
  
      foreach ($this-&gt;cart-&gt;contents() as $key) {
              if($cart['id']==$key['id']){
                  $cart['rowid']=$key['rowid'];
                  $cart['qty']=$this-&gt;input-&gt;post('kol');
                  $this-&gt;cart-&gt;update($cart);
              } else {
                  $this-&gt;cart-&gt;insert($cart);
              }
          }
      print_r($this-&gt;cart-&gt;contents());
  }
  </code></pre>