FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


How to add items to cart?





AOP Web Development
Hello guys, im in the middle of the development and it is my first time to develop an shopping cart. and my problem is how can i add the item to cart by using session... do have any idea.. please share it to me! thanks a lot! Laughing Laughing Laughing Laughing Laughing Laughing Laughing Laughing Laughing Laughing
mathiaus
This is how I would do it, whether it works well or not I don't know.
Code:
$_SESSION[cart][item_id][quantity]

Obviously replacing item)id with the item's id and quantity with the number being brought.
I want to buy 2 bannana's, I find bannanas, eneter 2 into the textbox and click buy (or similar button). Item id will probably be in a hidden field, quantity is in the textbox, so just add the var. (add validation for posted fields though [not mentione din below code sorry] )
Code:
$item_id=$_POST['item_id'];
$quantity = $_POST['quantity'];
$_SESSION[cart][$item_id][$quantity] = TRUE


On the cart page, I may delete 1 of the 2 items and click update. Remove the session cart var, and recalculate everything.
Code:
unset($array[cart]);


Hexkid will probably reply now with a method 10x better Razz
AOP Web Development
can you do multiple session?

just like what your post $_SESSION[cart][item_id][qty]

can you give me an example how to use it... because i only tried 1 at a time..
Related topics
Add to Cart component for flash
Add To Cart Button Missing in IE
Shopping Cart....
creating shopping cart
GSIS - Now Online!
Adding eCommerce
PayPal Experience
register a domain in .be for 0 FH$
Guide to set up a free .be domain name.
Does anyone know where I could get a FREE domain name?
FEEDBACK PLEASE! My art glass website.
Need help wi th IPN's ....
~~total SEARCH ENGINE OPTIMIZATION for your site!~~
Free .info Domains Names (LIMITED TIME OFFER)
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.