Problems in php to add products in a shop cart
<p>I have these 3 classes: <code>shopping cart</code>-><code>orders</code>-><code>products</code>.</p>

<p>First I add a product, when I add the second, I compare with other products in the array <code>products</code> in the object <code>orders</code>. <code>if count($product)==0</code>, then add the firs product
if <code>count&gt;0</code>, I compare the id´s of the products in the array with the new product I want to add :</p>

<pre><code>    public function setProduct($product,$new_quantity){
        if($this-&gt;num_product == 0) {
            $this-&gt;product[$this-&gt;num_product]=$product;
            $this-&gt;num_product++;
        } else if($this-&gt;num_product &gt; 0) {
            for($i=0; $i &lt; $this-&gt;num_product; $i++) {
                if($this-&gt;product[$i]-&gt;getIdproduct() == $product-&gt;getIdproduct()) {
                    $this-&gt;product[$i]-&gt;setQuantity($this-&gt;product[$i]-&gt;getquantity()+$new_quantity);
                    break;
                } else {
                    continue;
                }
                $this-&gt;product[$this-&gt;num_product]=$product;
                $this-&gt;num_product++;
            }

        }
    }
</code></pre>

<p>When I finish the comparison, I have to add these new product but this doesn't work. What is my mistake?</p>
