OO shopping cart class + product class interaction
I would have done it in the following way:

&lt;?php
    class Product {
        private $id;
        private $type;
        private $price;


        public function __toString() {
            return  "your way to display the Product object ie: &lt;p&gt; The id is: $this-&gt;getId &lt;/p&gt; ";
        }


        public function getId()
        {
            return $this-&gt;id;
        }


        public function setId($id)
        {
            $this-&gt;id = $id;
        }

        public function getType()
        {
            return $this-&gt;type;
        }

        public function setType($type)
        {
            $this-&gt;type = $type;
        }

        public function getPrice()
        {
            return $this-&gt;price;
        }

        public function setPrice($price)
        {
            $this-&gt;price = $price;
        }

    }

    class Cart {
        private $products;
        private $id;

        public function getProducts()
        {
            return $this-&gt;products;
        }


        public function addProduct(Product $product)
        {
            $this-&gt;products[] = $product;
        }


        public function getId()
        {
            return $this-&gt;id;
        }


        public function setId($id)
        {
            $this-&gt;id = $id;
        }

        /**
         * Returns the sum off all products prices
         * array_reduce docs: http://php.net/manual/en/function.array-reduce.php
         */
        public function total(){
            return array_reduce($this-&gt;getProducts(), function($carry, $product){
                return $carry + $product-&gt;getPrice();
            });
        }

    }


It's important to note here that you are managing objects, so you will need some Object Relational Mapper to persist objects on a DB, such as Doctrine.

You need to separate concerns in a MVC architecture, the logic of your domain the 'M' of MVC (in this case the shopping cart) reside in a object model (Product + cart) . Then you need the 'C' here you tell the cart that you want to add a new product:

class Controller {
        public function someAction(){
            $product = new Product();
            $product-&gt;setId(1);
            $product-&gt;setPrice(100.00);
            $product-&gt;setType(3); //Id of the type

            $cart = new Cart;
            $cart-&gt;addProduct($product);

            $cart-&gt;total(); //Will return 100.00
            //Logic to obtain twig engine
            return $twig-&gt;render('Template', ['cart' =&gt; $cart]); //returns HTML
        }
    }


And finally the V of the MVC there is where you build your HTML:

Using a template engine like Twig:

     &lt;html&gt;
        &lt;body&gt;
        Total: {{cart.total()}}
           &lt;ol&gt;
              {% for product in cart.products %}
                 &lt;li&gt;{{product}}&lt;/li&gt;
              {% else %}
                 &lt;li&gt;Empty cart&lt;/li&gt;
              {% endfor %}
           &lt;/ol&gt;
        &lt;/body&gt;
    &lt;/html&gt;


Of course building this architecture on your own could be really complicated there is when frameworks like symfony kick in http://symfony.com/. It's just a personal recommendation.

Also, take a look at OOP patterns. They will make your life easier and you will learn how to program good architectures for models.