Wrox Programmer Forums
|
BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8
This is the forum to discuss the Wrox book Professional CodeIgniter by Thomas Myer; ISBN: 9780470282458
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 4th, 2009, 04:58 PM
Authorized User
 
Join Date: Nov 2009
Posts: 26
Thanks: 3
Thanked 0 Times in 0 Posts
Unhappy Add to cart problem

I freshly installed Claudia's Kids in my localhost.

I deleted my cookies in FF.

Then when I click Add to cart button, I get the following errors.

Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined index: cart

Filename: models/morders.php

Line Number: 10
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\codeigniter_shopping_original\system\libraries\Exceptions.php:164)

Filename: libraries/Session.php

Line Number: 295
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\codeigniter_shopping_original\system\libraries\Exceptions.php:164)

Filename: helpers/url_helper.php

Line Number: 485
The line 10 in morders.php is the following.

Code:
function updateCart($productid,$fullproduct){
	//pull in existing cart first!
	$cart = $_SESSION['cart'];//$this->session->userdata('cart');
	$productid = id_clean($productid);
	$totalprice = 0;
	if (count($fullproduct)){
..
...

I go back or refresh it then it shows no error messages.

I repeated again. Deleted cookies, then visit the home page then click "Add to cart button", then again the same error message.

Could anyone tell me how to fix this problem?

Regards.

Last edited by phpcoder101; November 4th, 2009 at 05:09 PM..
 
Old November 5th, 2009, 11:36 AM
Wrox Author
 
Join Date: May 2008
Posts: 53
Thanks: 0
Thanked 5 Times in 5 Posts
Default dammit!

Another bit of code that didn't make it into final release of book. GRRRRRR.

The updateCart() function should start out like this.

Code:
function updateCart($productid,$fullproduct){
	//pull in existing cart first!
	if (isset($_SESSION['cart'])){
		$cart = $_SESSION['cart'];
	}else{
		$cart = array();
	}
....
__________________
Thomas Myer
Author, Professional CodeIgniter
http://www.tripledogs.com
The Following User Says Thank You to myerman For This Useful Post:
phpcoder101 (November 5th, 2009)
 
Old November 5th, 2009, 12:42 PM
Authorized User
 
Join Date: Nov 2009
Posts: 26
Thanks: 3
Thanked 0 Times in 0 Posts
Talking Thanks for your help!

Quote:
Another bit of code that didn't make it into final release of book. GRRRRRR.
Is there any list for the corrections?
Or purhaps a new version of download link?

Thanks for your help.
 
Old December 3rd, 2009, 02:10 PM
Registered User
 
Join Date: Dec 2009
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Question add to cart: problem

I've installed all the examples of the book up to page 112 (Adding Products to a Shopping Cart).

Now, when I click Add to Cart I get the following errors:

--------------------------------------
A PHP Error was encountered
Severity: Notice

Message: Undefined property: Welcome::$MOrders

Filename: controllers/welcome.php

Line Number: 69

Fatal error: Call to a member function updateCart() on a non-object in C:\Programs\xampp\htdocs\CI-CLAUDIA\system\application\controllers\welcome.php on line 69
---------------------------------------

Here is my welcome.php:

Code:
<?php

class Welcome extends Controller {
	function __construct(){
		parent::Controller();	
	}
	
	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');
	}
	
	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');
	}	
	
	function subcat()
	{
	}	
	
	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');
	}	
	
	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'])){
				$data['main'] = '';
				$data['navlist'] = $this->MCats->getCategoriesNav();
				$this->load->vars($data);
				$this->load->view('template');	
			}else{
				redirect('welcome/index','refresh');
			}
		}
	}
	
	function search()
	{
		if ($this->input->post('term')) {
			$data['results'] = $this->MProducts->search($this->input->post('term'));
		} else {
			redirect('welcome/index','refresh');
		}
		
		$data['title'] = "Claudia's Kids | Search Results";
		$data['main'] = 'search';
		$data['navlist'] = $this->MCats->getCategoriesNav();
		
		$this->load->vars($data);
		$this->load->view('template');
	}	
	
	function about_us()
	{
	}	
	
	function contact()
	{
	}	
	
	function privacy()
	{
	}	
}

?>
Could anyone please tell me how to fix this problem?

Thanks for your help.
 
Old December 3rd, 2009, 03:59 PM
Wrox Author
 
Join Date: May 2008
Posts: 53
Thanks: 0
Thanked 5 Times in 5 Posts
Default did you autoload the models?

look in the config/config.php file, see if you're autoloading models
__________________
Thomas Myer
Author, Professional CodeIgniter
http://www.tripledogs.com
The Following User Says Thank You to myerman For This Useful Post:
violoboe (December 4th, 2009)
 
Old December 4th, 2009, 07:00 AM
Registered User
 
Join Date: Dec 2009
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Smile add to cart problem: I forgot to autoload MOrders

Thank you very much for your prompt reply.

Actually I forgot to autoload model MOrders in config/autoload.php





Similar Threads
Thread Thread Starter Forum Replies Last Post
add to cart error haines BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 March 17th, 2008 05:49 PM
add multiple items to cart saf BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 January 8th, 2007 02:50 PM
shopping cart problem Adam H-W Javascript 2 November 14th, 2006 12:57 PM
having problem with shopping cart radonfile Classic ASP Databases 0 September 26th, 2003 12:42 PM
Add to Cart Error: Object not set as an instance damartman All Other Wrox Books 0 June 27th, 2003 05:45 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.