Join the social network of Tech Nerds, increase skill rank, get work, manage projects...

 1 Answer(s)

  • I have done this using cakephp. Hope this will be helpful to you. To add product to your cart add the following function to your Controller file:

    public function product(){
        //find all products
        $products = $this->Product->find('all');
        //set counter to display number of products in a cart
        $counter = 0;
        if ($this->Session->read('Counter')) {
            $counter = $this->Session->read('Counter');
        //pass variable to view
        $this->set(compact('products', 'counter'));
    function cart($id=null)
       $this->Product->id = $id;
             throw new NotFoundException(__('Invalid product'));
        $productsInCart = $this->Session->read('Cart');
        $this->Session->write('Cart.' . $amount, $this->Product->read(null, $id));  
        $this->Session->write('Counter', $amount + 1);
        $this->Session->setFlash(__('Product added to cart'));
     function showcart()
         $cart = array();
        if ($this->Session->check('Cart')) {
            $cart = $this->Session->read('Cart');

    and then create the view file for product and showcart functions. Kindly make changes in the terms accordingly. All the best!

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: