My cart class manages the shopping cart facility which almost every e-commerce site requires these days. This class does not do checkout with paypal, google check out or with any such similar services. But you can very easily manage the items being put into and taken away from the cart.
you can download the file from here:
http://nasaralla.googlecode.com/files/shopping_cart.php
And like in the following example can start managing your items:
___________________________________________________
//include the file
include("shopping_cart.php");
//start a session
session_start();
//initialize session variables
$_SESSION["item_list"] = array();
$_SESSION["item_total"] = 0;
//creating some items
$itm1 = new item("1","T-shirt","clothing","fcuk", "10.00", "cotton t-shirt", "image_url_not_available");
$itm2 = new item("2","Trouser","clothing","fcuk", "15.00", "Khaki trouser", "image_url_not_available");
$itm3 = new item("3","Cap","clothing","Next", "5.00", "all size cap", "image_url_not_available");
$itm4 = new item("4","jacket","formal","Austin reed", "100.00", "bond casino royal style", "image_url_not_available");
$itm5 = new item("5","Shoes","formal","Aldo", "50.00", "black naughty boy", "image_url_not_available");
//create your cart
$cart = new shopping_cart();
//add items to your cart
$cart->add_to_cart($itm1);
$cart->add_to_cart($itm2);
$cart->add_to_cart($itm3);
$cart->add_to_cart($itm4);
$cart->add_to_cart($itm5);
//print xml based status of the cart
$cart->print_cart_status();
//remove item in 3rd position (4th item)
$cart->remove_element(3);
//print xml based status of the cart
$cart->print_cart_status();
//end session
session_destroy();
___________________________________________________
And the xml output is like the following:
___________________________________________________
___________________________________________________