Error! this program is running in folder: $thisDir ZippyCart must be installed in folder: $req\n"; exit; } if(!is_writable($thisDir)){ print "
Error! the folder: $thisDir is not writable by this script\n";
  exit;
}




if($_POST['emptycart']){
    foreach($_COOKIE as $n =>$v){if(!strpos($n,"ustomer_")){
		setcookie( $n, '', -10000, $cookie_path, ".$server");
	}}
  header("Location: zpdemo.php");   exit;
} ####################################################################

if($_POST['destChange']){  
  foreach($_COOKIE as $n =>$v){if(strpos($n,"ustomer_")){
      setcookie( $n, '', -10000, $cookie_path, ".$server");
  }}
  header("Location: zpdemo.php");   exit;
} ####################################################################

if($_POST['update']){
  $neworder=""; $separator="";
  foreach($_POST as $n => $v){
    if(strpos($n,"ata_")){
      list ($x,$y)=split("_",$n);
	  if($_POST['sel_'.$y]){continue;} 
      if($neworder){$separator='][';} 
	  $neworder.=$separator.$_POST['qty_'.$y]."|".$_POST['data_'.$y];
    }
  }
  setcookie( "order", $neworder, $cookie_life, $cookie_path, ".$server"); 
  if($_POST['customer_country']){
    setcookie( "customer_country", $_POST['customer_country'], 
	$cookie_life,$cookie_path, ".$server"); 
  }
  if($_POST['customer_state']){
    setcookie( "customer_state", $_POST['customer_state'], 
	$cookie_life,$cookie_path, ".$server"); 
  }
  if($_POST['customer_zip']){
    setcookie( "customer_zip", $_POST['customer_zip'], 
	$cookie_life,$cookie_path, ".$server"); 
  } 
  if($_POST['expedite']){
    setcookie( "expedite", "1", $cookie_life, $cookie_path, ".$server"); 
  }else{
    setcookie( "expedite", "0", $cookie_life, $cookie_path, ".$server");   
  }    
  header("Location: zpdemo.php");  exit;
} ####################################################################

if($_POST['cmd']){                           ## cmd field means this is an order   
   $item=$_POST['item_number'];   $separator='][';    $opts=""; 
   if(! $item){$item=substr(time(),5);}      ## must have unique item number
   $title=$_POST['item_name'];
   $price=$_POST['amount'];
   $class=$_POST['item_class'];              ## class is reserved for user
   $price=str_replace("$","",$price);        ## remove leading dollar sign
   $qty= $_POST['add'];                      ## quantity is required or exit
   if(!$qty){  header("Location: zpdemo.php");  exit;} 
   $ounces=round($_POST['ounces']+.01);      ## convert to ounces               
   $ounces+=round(($_POST['pounds'] * 16)+.01);  
   foreach($_POST as $n =>$v){               ## build options list 
    if(false !==strpos($n, "on") || false !==strpos($n, "os")){$opts.="$v ";}
   }
   $orderline=$_COOKIE['order'];             
   if($orderline){$separator='][';}else{$separator='';}            
   $orderline.=$separator;
   $orderline.="$qty|$item|$title|$price|$opts|$class|$ounces";
   setcookie( "order", $orderline, $cookie_life, $cookie_path, ".$server"); 
   header("Location: zpdemo.php");
} ####################################################################

if($_COOKIE['order']){
  $ctr=0;  $prodtotal=0;   $ounces=0;   $comparescript="";
  $itm_count=0; $itemtax=0;  $separator='\]\['; 
  $rows=split($separator,$_COOKIE['order']);   
  foreach($rows as $row){                      
    $dta=split("\|",$row);                ## parts of row           
    $ounces+=($dta[6] * $dta[0]);         ## qty times weight each        
    $amt=fmtDec( $dta[0] * $dta[3]);      ## price time qty     
	$itm_count+=$dta[0];                  ## total items       
    $prodtotal+=($dta[0] * $dta[3]);      ## running total amount      
    $comparescript.='oval["qty_'.$ctr.'"]="'.$dta[0].'";';  
    if($clr=="#EBF1E7"){$clr="#EBE2DD";}else{$clr="#EBF1E7";}
$orderTableRows.=<<  
 
    
 $dta[2] 
no. $dta[1] $dta[4] $amt ROW; $invoiceRows.=<< $dta[0] $dta[3] $dta[2]
#$dta[1] #$dta[4] $amt INV; $ctr++; } ################################### end loop through orderlines }else{ $cartempty=1; $orderTableRows=" Cart is empty!"; } ######################################## end test for order cookie $orderlines=$ctr-1; $Fprodtotal=fmtDec($prodtotal); if($clr=="#EBF1E7"){$clr="#EBE2DD";}else{$clr="#EBF1E7";} if($clr=="#EBF1E7"){$shipclr="#EBE2DD";}else{$shipclr="#EBF1E7";} ################################## shipping calculation begins here $overweight=""; $disableco="disabled"; if($_COOKIE['customer_country'] && $_COOKIE['customer_zip']){ $disableco=""; // list($ctry,$code)=split(",",$_COOKIE['customer_country']); if(!$cartempty){ $orderweight = $ounces; if($_COOKIE['customer_country']=="United States"){ $shpchg=getDomSH($_COOKIE['customer_zip'], $_COOKIE['expedite'], $orderweight); $invshiptext=" *S&H charge for delivery to zip "; $invshiptext.=$_COOKIE['customer_zip']." - US/".$_COOKIE['customer_state']; }else{ $shpchg=getIntSH($_COOKIE['customer_country'], $_COOKIE['expedite'], $orderweight); $invshiptext=" *S&H charge for delivery to ".$_COOKIE['customer_country']; } }else{ $invshiptext="Shipping to: $ctry "; if($ctry=="United States"){ $invshiptext.=$_COOKIE['customer_state'].", ".$_COOKIE['customer_zip']; } } $shRowContent='       '; $shRowContent.=$invshiptext; }else{ $countries=getCountries(); $options=""; if($countries){ foreach($countries as $ctry){ $options.=""; } } $shpchg=""; $shRowContent=<< $options State Zip Code IMPORTANT!! You must indicate the destination before continuing! ** The zip code is required for US destinations. ZippyCart™ requires this information to accurately calculate shipping charges for the order. SEL; $shipScript=' document.forms[0].update.disabled=false var nz=Number(document.forms[0].customer_zip.value); var c=document.forms[0].customer_country.selectedIndex; var z=document.forms[0].customer_zip.value; var s=document.forms[0].customer_state.value; if(c==0 && (z=="" || z=="N/A" || s=="" || nz<10 || nz >99999)){ document.forms[0].update.disabled=true document.forms[0].checkout.disabled=true alert("Please provide accurate delivery information!"); return false; }'; } $shpchg=fmtDec($shpchg); $shtotShow=$shpchg; $grandtotal=fmtDec($tax + $prodtotal + $shpchg); if($_POST['checkout']){ if(!$_COOKIE['customer_country']){ ## avoid checkout without destination header("Location: zpdemo.php"); exit; } sendHeader(); print invoice($invoiceRows); exit; } ########################################### MAIN CART PAGE BEGINS HERE if($cartempty){$disableco="disabled";} $style=style(); $javascript1=getScript1($orderlines, $comparescript,$shipScript); sendHeader(); $testpart=testcart(); print << $javascript1 $style
ZippyCart Demo
$orderTableRows $taxrow $exprow
Qty Remove Item Options Price
Product Total: ($itm_count items)   $Fprodtotal 
$shRowContent $shtotShow 
(USD) Order Total: $minordernotice  $grandtotal 
     
 
To remove an item, check 'remove' then click 'update'

ZippyCart™ Demo

You are using the demo version of ZippyCart. Once the active version is installed, you may wish to use this area to describe your shipping policies or provide links to other features of your website. Any valid HTML and/or script may be used. Simply edit the zippycart code to match your specific needs.
$testpart PAGE; exit; function invoice($rows){ global $cookie_path, $root, $server, $prodtotal, $shpchg, $taxrow, $itm_count, $tax, $invshiptext, $grandtotal, $shipclr, $cookie_life; $fpt=fmtDec($prodtotal);$shtot=fmtDec($shpchg);$shtotShow=$shtot; $totaldue=$grandtotal; $orn=getOrderNo(); setcookie( "order_no", $orn, $cookie_life, $cookie_path, ".$server"); $style=style(); $script=getScript2(); if($shipclr=="#EBF1E7"){$bgcolor="#EBE2DD";}else{$bgcolor="#EBF1E7";} return << $script $style $rows$taxrow $revisedtotal
Order No. $orn
Qty Ea. Item Options Price
(USD) Order Total:   $fpt 
$invshiptext $expedited   $shtotShow  
Total due for order # $orn:   $totaldue 

Checkout is disabled in the demo version

You are using the demo version of ZippyCart™. When installed, the active version will accept customer shipping information from this screen. Domestic or International shipping informations is entered and the customer is taken to the appropriate payment service.

As with all visible content, the ZippyCart owner may edit and customize the information shown here by editing the ZippyCart script.

INVOICE; } function fmtDec($n){ return number_format($n,2,".",""); } ############################################################## function style(){ return<< STYLE; } ############################################################## function getOrderNo(){ global $thisDir; if($_COOKIE['order_no']){ return $_COOKIE['order_no']; }else{ return substr(time(),-8,6); } } ################################################################## function getIntSH($ctry, $expedite, $oz){ $stdrates['Canada']="6,6,6,6,6,6,6,6,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,14,14,14,14,14,14,14,14,16,16,16,16,16,16,16,16,18,18,18,18,18,18,18,18"; $rushrates['Canada']="15.50,15.50,15.50,15.50,15.50,15.50,15.50,15.50,16.25,16.25,16.25,16.25,16.25,16.25,16.25,16.25,17.00,17.00,17.00,17.00,17.00,17.00,17.00,17.00,17.00,17.00,17.00,17.00,17.00,17.00,17.00,17.00,18.25,18.25,18.25,18.25,18.25,18.25,18.25,18.25,18.25,18.25,18.25,18.25,18.25,18.25,18.25,18.25,19.25,19.25,19.25,19.25,19.25,19.25,19.25,19.25,19.25,19.25,19.25,19.25,19.25,19.25,19.25,19.25"; if(($expedite && $rushrates[$ctry])){ $rates=split(',',$rushrates[$ctry]); $ret=$rates[$oz]; }else{ $rates=split(',',$stdrates[$ctry]); $ret=$rates[$oz]; } if(!$ret){$ret="50.00";} ## return an absurd number to indicate an error return $ret; } #################################################################### function getintexpediterow($ctry,$oz){ global $force_expedite; if(!$_COOKIE['expedite']){ $chg=fmtDec(getIntSH($ctry,1,$oz)); $ret=<< This order is eligible for expedited shipment for a charge of $chg.
Check here if you wish to select expedited shipment. RETA; }else{ $ret=<<   You have selected expedited shipment! RETB; } return $ret; } ################################################################### function getDomSH($z,$expedite,$oz){ $zip=substr($z,0,3); if($oz <14){ ## rates to 13 ounces - delete this section to force only pound rates $ozrate=split(',',".37,.37,.60,.83,1.06,1.29,1.52,1.75,1.98,2.21,2.44,2.67,2.90,3.13"); return $ozrate[$oz]; } $pounds=floor($oz / 16.001)+1; $r=<< var oval=new Array(); var olines=$orderlines; var blnk; $comparescript function chkForChange(){ if(document.forms.frm1.customer_state && document.forms.frm1.customer_zip){ var z=document.forms.frm1.customer_state.value var s=document.forms.frm1.customer_zip.value if(z!="$z" || s!="$s"){ alert("Make sure your shipping info is correct then click 'update' to record your changes"); blink(); return false } } return true } function isQtyChanged(n,v){ if(v!=oval[n]){noblink();blink()}else{noblink()} } function isRemove(yn){ if(yn){ noblink();blink()}else{noblink()} } function blink(){ document.forms[0].update.disabled=false clearTimeout(blnk) var el=document.forms.frm1.update if (el.style.color=="orange"){ el.style.color="black"; }else{ el.style.color="orange" } blnk=setTimeout("blink()",500) } function noblink(){ var el=document.forms.frm1.update; el.style.color="black"; clearTimeout(blnk) } function chkzone(z){ $shipScript } function chkstate(s){ return true } function form_check(){ $shipScript } function init(){ var t=new Date(); document.forms.frm1.user_date.value=Number(t.getTime()/1000); self.resizeTo(650,screen.availHeight); // self.moveTo(screen.availWidth-650,0); self.focus() } SCRIPT; } function getScript2(){ $scrpt=""; foreach($_COOKIE as $n => $v){ if(false !== strpos($n,"customer_")){ $scrpt.="frm.".$n.".value=\"$v\";\n"; } } list($ct,$cd)=split(",",$_COOKIE['customer_country']); $scrpt.="frm.show_country.value=\"$ct\";\n"; if($_COOKIE['customer_zip']=="N/A"){ $chxdata="name,address1,city,email"; }else{ $chxdata="name,address1,city,state,email"; } return << SCRIPT; } function getCountries(){ $countries=' Canada Aruba Australia Austria Bahamas Barbados Belgium Brazil Chile China Colombia Costa Rica Czech Republic Denmark '; return split("\n",trim($countries)); } ########################################### END COUNTRY LIST function testcart(){ return <<
Test Order Form (this area is not part of the active script. Present in demo only) Use the forms below to add items to the cart. Weight limit for the demo is 4 pounds.
Order Widget #1 ($9.99)
Color: Size:
Item Weight (ounces)
Order Widget #2 ($11.95)
Demo Widget #2 (no options)

Item Weight (ounces)
PAGE; } ####################################################################### ?>