Unset Session in Php.

else if($_REQUEST['command']=='clear')
{
unset($_SESSION['cart']);
}


<script language="javascript">
function del(pid){
if(confirm('Do you really mean to delete this item')){
document.frm1.pid.value=pid;
document.frm1.command.value='delete';
document.frm1.submit();
}
}
function clear_cart(){
if(confirm('This will empty your shopping cart, continue?')){
document.frm1.command.value='clear';
document.frm1.submit();
}
}
function update_cart(){
document.frm1.command.value='update';
document.frm1.submit();
}


</script>




function addtocart($pid,$q,$psize,$color){
if($pid<1 or $q<1) return;

if(is_array($_SESSION['cart'])){
if(product_exists($pid)) return;
$max=count($_SESSION['cart']);
$_SESSION['cart'][$max]['productid']=$pid;
$_SESSION['cart'][$max]['qty']=$q;
$_SESSION['cart'][$max]['size']=$psize;
$_SESSION['cart'][$max]['color']=$color;

}
else{
$_SESSION['cart']=array();
$_SESSION['cart'][0]['productid']=$pid;
$_SESSION['cart'][0]['qty']=$q;
$_SESSION['cart'][0]['size']=$psize;
$_SESSION['cart'][$max]['color']=$color;

}
}





call clear_cart() function to empty cart.

Popular posts from this blog

Simple Sign up design. Android.

Cart page design in android.

Set Date on jDateChooser and retrieve record from database.