<?php
session_start();
//unset($_SESSION['m_cart']); //for testing purposes you can clear the session to start over
//session_destroy();
require "basketclass.php";
$bas=new basket();
$bas->init('m_cart'); //just specify which session name do you want to supply for the basket, in this example we use 'm_cart'
# here we add 3 quantity of the product with the id of 100, always add the ':::' after the id, you'll see why in the next example
//$bas->add_cart("100:::",3);
# here we add 5 quantity of the product with the id of 1 , and color black, seperated by ::: , why? because sometimes you have the same product but differnt colors or different shapes , therefor the id stays the same , we just add the extra info after ::: , it can be repeated with other things too , for ex: $bas->add_cart("1:::black:::big",5) , here we added 5 of the product with the id having black color and medium shaped. Later on you can explode the :::'s and get the valyes in an array as u like
//$bas->add_cart("1:::black",5);
# here we add 1 quantity of the product with the id of 3 , and color white, seperated by :::
//$bas->add_cart("3:::white",1);
#here we update the cart when the buyer wishes to buy 4 more of these
//$bas->update_cart("3:::white",5);
# here we remove all the orders having product id of 1 and color black
//$bas->remove_cart("1:::black");
# here we remove all the orders having product id of 100
//$bas->remove_cart("100:::");
# here we remove all the orders having product id of 3
//$bas->remove_cart("3:::white");
#if you want to empty the basket , just use the syntax below
//$bas->removeall_cart();
if(!$bas->get_cart()){ //checking if the cart is empty or not
echo "no basket found";
}else{
print_r($bas->get_cart()); //this returns the values stored in a array , you can iterate and get the values after that
}
echo "<BR>";
echo $bas->count_cart()." items found"; //for ex if the buyer bought 3 black pencils, 2 shirts, and 5 books , the value would be 3
echo "<BR>";
echo $bas->countall_cart()." total items found"; //for ex if the buyer bought 3 black pencils, 2 shirts, and 5 books , the value would be 10?>
|