Jump to content

Recommended Posts

You can see here that it already queries the database and send it to the page but I have tried several times to code it and keep getting something like an incompatible error?

 

http://d882518.u36.rickettsweb.com/test/subcategory.php?sCatID=32

 

Pulling my hair out here...Here is what I think it should be so far? help please.

 


<?php
class cart
{
	private $session=null;
	private $items=array();
	private static $cartObj=null;

	private function __construct(&$session)
	{
		if(!self::$cartObj) self::$cartObj =& $this;
		$this->session =& $session;
		$this->session->registerSessionData($this);
	}

	public static function getInstance(&$session)
	{
		if(self::$cartObj) return self::$cartObj;
		return new cart($session);
	}

	public function addItem($id, $qty)
	{
		$this->items[$id] = $qty;
	}

	public function getItemList()
	{
		$ret = array();

		foreach($this->items as $itemID => $itemQty) $ret[]=$itemID;

		return $ret;
	}

	public function getItemQty($itemID)
	{
		if(!isset($this->items[$itemID])) return 0;
		return $this->items[$itemID];
	}

	public function numItems()
	{
		return count($this->items);
	}

	public function __sleep()
	{
		return array('items');
	}
	public function __wakeup()
	{
		if(!self::$cartObj) self::$cartObj =& $this;
	}
}
?>

 

 

there are alot of scripts out there for shopping carts including gateways for payments such as paypal

 

 

if u have fantastico on you website control panel then use that and you will have free scripts there starting it from scratch u need a lot of time and good coding skills

 

thats my suggestion lol

nadeemshafi9 lol I know your making fun of me but do you have any suggestions?

 

im not making fun, i wont lie im a PHP pro but i work with PHP 4 not 5 so i dont get the chance to do pure oop with session controle in the class for its own instance like you do and it looks like its got soo much potential.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.