Welcome Guest, Not a member yet? Register   Sign In
Cart class problem

i am designing a website with a shopping cart and it works perfectly on my wamp server locally. Unfortunately it throws an error when uploaded onto an online server.

Fatal error: Call to undefined method CI_Cart::total_quantity() etc

You can see the error if you go to:


and click Add to Cart for any item. The session cookie is definitely created and seems to be fine but the error goes if I delete the cookie.

The database seems to be fine as the test items on the page are all generated from a model query.

Add to Cart links to a method called add which looks like this:

function add() {

  $product = $this->Products_model->get_item($this->input->post('id'));
  $insert = array(
   'id' => $this->input->post('id'),
   'qty' => 1,
   'name' => $product->name,
   'price' => $product->price


The actual error is thown by the telltale cart panel in the page header and the code looks like this:

<?php if ($cart = $this->cart->contents()): ?>
    <td class="mycart">My Shopping Cart</td>
    <td class="items">&lt;?php echo $this->cart->total_quantity(); ?&gt;</td>
    <td><span>Total:</span> £&lt;?php echo $this->cart->total(); ?&gt;</td>
&lt;?php else: ?&gt;
  <h3>Shopping Cart is empty</h3>
&lt;?php endif; ?&gt;

total_quantity() is my own method to deliver the total number of items allowing for multiple quantities.

Like I say, it all works fine locally. I would be very grateful if amyone could suggest where it might be going wrong online.

Messages In This Thread
Cart class problem - by El Forum - 12-14-2011, 03:00 PM

Theme © iAndrew 2016 - Forum software by © MyBB