mjahkoh Posted March 10, 2010 Share Posted March 10, 2010 I have incorporated the Jpmaster77 login system into my website. I now want to add wfcart shopping cart. Now i incorporated all the carts variables into the login session but it doesnt work. Can two sessions work side by side or how is it achieved. Jackson Quote Link to comment https://forums.phpfreaks.com/topic/194764-how-to-incorporate-cart-into-system/ Share on other sites More sharing options...
mjahkoh Posted March 10, 2010 Author Share Posted March 10, 2010 Reframing my question, since I have a login framework (jpmaster) with a session, can I assimilate the cart session into the login session. Any body done this. before Quote Link to comment https://forums.phpfreaks.com/topic/194764-how-to-incorporate-cart-into-system/#findComment-1024239 Share on other sites More sharing options...
mjahkoh Posted March 11, 2010 Author Share Posted March 11, 2010 <?php I downloaded a cart from wfcart which I assimiliated into my session having a loggin procedure(jpmasters). The problem is when I shop the details of ones pages transaction are not available in another page and vice versa and then disapppear. This is my code //Class session { /* Class constructor */ function Session(){ $this->time = time(); $this->startSession(); } var $total = 0; var $itemcount = 0; var $items = array(); var $itemprices = array(); var $itemqtys = array(); var $iteminfo = array(); function get_contents() { // gets cart contents $items = array(); foreach($this->items as $tmp_item) { $item = FALSE; $item['id'] = $tmp_item; $item['qty'] = $this->itemqtys[$tmp_item]; $item['price'] = $this->itemprices[$tmp_item]; $item['info'] = $this->iteminfo[$tmp_item]; $item['subtotal'] = $item['qty'] * $item['price']; $items[] = $item; } return $items; } /* end of get_contents */ function add_item($itemid,$qty=1,$price = FALSE, $info = FALSE) { global $database; // adds an item to cart if(!$price) { $price = $database->wf_get_price($itemid)*$qty; } if(!$info) { $info = $database->CartProductInfo($itemid);} if($this->itemqtys[$itemid] > 0) { // the item is already in the cart.. // so we'll just increase the quantity $this->itemqtys[$itemid] = $qty + $this->itemqtys[$itemid]; $this->_update_total(); } else { echo 'itemid query '.$itemid.'<br>'; echo 'qty query '.$qty.'<br>'; echo 'price query '.$price.'<br>'; echo 'info query '.$info.'<br>'; $this->items[]=$itemid; $this->itemqtys[$itemid] = $qty; $this->itemprices[$itemid] = $price; $this->iteminfo[$itemid] = $info; } $this->_update_total(); } /* end of add_item */ //how I add into the cart if($_POST['Submit']) { $product = $products[$_POST['id']]; $session->add_item($_GET['uID'],$_POST['qty'],$ProductInfo["price"],$ProductInfo["synopsis"]); } //how I retrieve the cart contents if($session->itemcount > 0) { foreach($session->get_contents() as $item) { echo "<br />Item:<br/>"; echo "Code/ID :".$item['id']."<br/>"; echo "Quantity:".$item['qty']."<br/>"; echo "Price :$".number_format($item['price'],2)."<br/>"; echo "Info :".$item['info']."<br />"; echo "Subtotal :$".number_format($item['subtotal'],2)."<br />"; echo "<form method=post><input type='hidden' name='id' value='".$item['id']."'/><input type='submit' name='remove' value='Remove'/></form>"; } echo "---------------------<br>"; echo "total: $".number_format($cart->total,2); } else { echo "No items in cart"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/194764-how-to-incorporate-cart-into-system/#findComment-1024591 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.