Welcome Guest, Not a member yet? Register   Sign In
"Claudia's Kids" wrox shopping tutorial: function updateCart() on a non-object
#1

[eluser]antoniog[/eluser]
I'm doing the tutorial from the book "Professional CodeIgniter" published by Wrox.
At this point in the tutorial, click on "add to cart" above the image should appear to me the two following pieces of code, the first enclosed in a box with a red edge.

First part of code (in the box):
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Welcome::$MOrders

Filename: controllers/welcome.php

Line Number: 88

Second part of code:
Code:
Fatal error: Call to a member function updateCart() on a non-object in /home/youngtea/public_html/igniter/application/controllers/welcome.php on line 88

Code of welcome.php (the controller)
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {

/**
  * Index Page for this controller.
  *
  * Maps to the following URL
  *   http://example.com/index.php/welcome
  * - or -  
  *   http://example.com/index.php/welcome/index
  * - or -
  * Since this controller is set as the default controller in
  * config/routes.php, it's displayed at http://example.com/
  *
  * So any other public methods not prefixed with an underscore will
  * map to /index.php/welcome/<method_name>
  * @see http://ellislab.com/codeigniter/user-guide/general/urls.html
  *
  */

  function __construct()
  {
        // Call the Model constructor
        parent::__construct();
        $this->load->library('session');
        $this->load->library('cart');
  }

public function index()
{
    $data['title'] = "Welcome to Claudia's Kids";
    $data['navlist'] = $this->MCats->getCategoriesNav();
   $data['mainf'] = $this->MProducts->getMainFeature();
   $skip = $data['mainf']['id'];
   $data['sidef'] = $this->MProducts->getRandomProducts(3,$skip);
   $data['main'] = 'home';
    $this->load->vars($data);
    $this->load->view('template');
}

  public function cat($id)
  {
  $cat = $this->MCats->getCategory($id);
    if (!count($cat))
    {
      redirect('welcome/index','refresh');
    }
    $data['title'] = "Claudia's Kids | ".$cat['name'];
    if ($cat['parentid'] < 1)
    {
      $data['listing'] = $this->MCats->getSubCategories($id);
      $data['level'] = 1;
    }
    else
    {
      $data['listing'] = $this->MProducts->getProductsByCategory($id);
      $data['level'] = 2;
    }
    $data['category'] = $cat;
    $data['main'] = 'category';
    $data['navlist'] = $this->MCats->getCategoriesNav();
   $this->load->vars($data);
    $this->load->view('template');
}

  public function product($id)
  {
    $product = $this->MProducts->getProduct($id);
    if (!count($product))
    {
      redirect('welcome/index','refresh');
    }
    $data['grouplist'] = $this->MProducts->getProductsByGroup(3,$product['grouping'],$id);
    $data['product'] = $product;
    $data['title'] = "Claudia's Kids | ".$product['name'];
    $data['main'] = 'product';
    $data['navlist'] = $this->MCats->getCategoriesNav();
    $this->load->vars($data);
    $this->load->view('template');
}

  public function cart($productid=0)
{
    if ($productid > 0)
    {
      $fullproduct = $this->MProducts->getProduct($productid);
      $this->MOrders->updateCart($productid,$fullproduct);
      redirect('welcome/product/'.$productid, 'refresh');
    }
    else
    {
      $data['title'] = "Claudia's Kids | Shopping Cart";
      if (count($_SESSION['cart']) == true)
      {
        $data['main'] = 'shoppingcart';
        $data['navlist'] = $this->MCats->getCategoriesNav();
        $this->load->vars($data);
        $this->load->view('template');
      }
      else
      {
        redirect('welcome/index', 'refresh');
      }
    }
}

  public function search()
  {
  if ($this->input->post('term'))
    {
      $data['results'] = $this->MProducts->search($this->input->post('term'));
    }
    else
    {
      redirect('welcome/index','refresh');
    }
    $data['main'] = 'search';
    $data['title'] = "Claudia's Kids | Search Results";
    $data['navlist'] = $this->MCats->getCategoriesNav();
    $this->load->vars($data);
    $this->load->view('template');
}

  public function about_us()
{
  $this->load->vars($data);
    $this->load->view('template');
}

  public function privacy()
  {
    $this->load->vars($data);
    $this->load->view('template');
}

}

At the moment I can not get to the bottom of the issue.
Thank you for help to all.


Messages In This Thread
"Claudia's Kids" wrox shopping tutorial: function updateCart() on a non-object - by El Forum - 05-17-2012, 08:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB