Jump to content

Fatal error


hashstar

Recommended Posts

Hi AK, here is the code:

 

 

<?php

session_start();

include('include/includes.php');

$cart  = Cart::CreateInstance();

 

if(isset($_GET)){

foreach($_GET as $k=>$v){

$smarty->assign($k,$v);

}

}

if(isset($_GET['remove'])){

$cart->RemoveItems($_GET['remove'],1);

}

if(isset($_GET['removeAll'])){

$cart->RemoveItems($_GET['removeAll'],$_GET['counts']);

}

 

if(isset($_GET['emptyCart'])){

if($_GET['emptyCart']){

$cart->EmptyCart();

}}

 

if(isset($_GET['add'])){

 

$itemId = $_GET['add'];

$size = $_GET['size'];

if(isset($_GET['qty'])){

$qty = $_GET['qty']; }else{$qty = 1;}

$cart->addItems($itemId.'-'.$size, array($size,$itemId), $qty);

}

$cartBox = $cart->GetCart();

//print_r($cartBox);

$total = 0;

$subTotal = array();

$db = new DB();

$prods = $db->select("SELECT friendly,name,id FROM products");

$smarty->assign('prods',$prods);

if(is_array($cartBox)){

foreach($cartBox as $key=>$item){

$id = $cartBox[$key]['data']->_itemData[1];

$products = $db->select("SELECT detail,image,friendly,name FROM products WHERE id='$id'");

$detail = json_decode($products[0]['detail']);

foreach($detail->detail as $k=>$v){

if($k==$cartBox[$key]['data']->_itemData[0]){$price = $v;}

}

$cartBox[$key]['data']->_itemData[3] = $products[0]['image'];

$cartBox[$key]['data']->_itemData[6] = $products[0]['name'];

$cartBox[$key]['data']->_itemData[2] = $products[0]['friendly'];

$cartBox[$key]['data']->_itemData[5] = $price;

$sub = (int)$item['count']*$price;

$cartBox[$key]['data']->_itemData[4] = $sub;

$total += $sub;

}

}

$count = $cart->GetItemsCount();

 

$shipping = (int)0;

if($total>0&&$total<5){ $shipping = 2.99;

}elseif($total>5&&$total<10){ $shipping = 3.99;

}elseif($total>10&&$total<15){ $shipping = 4.99;

}elseif($total>15&&$total<20){ $shipping = 5.99;

}elseif($total>20&&$total<30){ $shipping = 6.99;

}elseif($total>30&&$total<40){ $shipping = 7.99;

}elseif($total>40&&$total<50){ $shipping = 8.99;

}elseif($total>50&&$total<60){ $shipping = 9.99;

}elseif($total>60&&$total<70){ $shipping = 10.99;

}elseif($total>70&&$total<80){ $shipping = 11.99;

}elseif($total>80&&$total<90){ $shipping = 12.99;

}elseif($total>90&&$total<100){ $shipping = 15.99;

}elseif($total>100&&$total<110){ $shipping = 16.99;

}elseif($total>110&&$total<120){ $shipping = 17.99;

}elseif($total>120&&$total<130){ $shipping = 18.99;

}elseif($total>130&&$total<140){ $shipping = 19.99;

}elseif($total>140&&$total<150){ $shipping = 20.99;

}elseif($total>150&&$total<160){ $shipping = 21.99;

}elseif($total>160&&$total<170){ $shipping = 22.99;

}elseif($total>170&&$total<180){ $shipping = 23.99;

}elseif($total>180){ $shipping = 24.99;

}

 

/*

0 - 4.99 = 2.99

5 - 9.99 = 3.99

10 - 14.99 = 4.99

15 - 19.99 = 5.99

20 - 29.99 = 6.99

30 - 39.99 = 7.99

40 - 49.99 = 8.99

50 - 69.99 = 9.99

70 - 99.99 = 10.99

100+ = 12.99

 

*/

if(isset($_GET['eushipping'])||(isset($_POST['rec_country'])&&$_POST['rec_country']!='uk')){

$shipping = ceil($total/30.00)*20.00;

}

 

/*

 

*/

if(isset($_GET['count'])){

echo (int)$count;

exit;

}

 

if(isset($_GET['order'])){

if($_GET['order']){

 

}}

 

if(isset($_GET['ajax'])){

$noAjax = $_GET['ajax'];

}else{

$noAjax = false;

}

 

$smarty->assign('noAjax',$noAjax);

 

 

if(isset($_GET['t'])){

$t=$_GET['t'].'.tpl';

}else{

$t = 'cart.tpl';

}

 

if(isset($_POST['cmd'])){

$_SESSION['paypal'] = $_POST;

//print_r($_POST);

}

if(isset($_POST['rec_houseA1'])){

 

$filename = time().'-'.rand(1,499);

$paypal = $_SESSION['paypal'];

unset($paypal['checkout_x']);

unset($paypal['checkout_y']);

 

$_SESSION['addresses'] = $_POST;

 

 

$File = 'sales/'.$filename.'.php';

$Handle = fopen($File, 'x');

fwrite($Handle,'<?

');

fwrite($Handle,'$cart = array(');

 

foreach($cartBox as $k=>$v){

   

fwrite($Handle,'"'.$k.'"=>array(');

foreach($v as $key=>$value){

 

if(is_object($value)){

fwrite($Handle,'"'.$key.'"=>(object)array(');

 

foreach($value as $keys=>$values){

if(is_array($values)){

fwrite($Handle,'"'.$keys.'"=>array(');

foreach($values as $keyd=>$valued){

fwrite($Handle,  '"'.$keyd.'"=>"'.$valued.'",');

}

fwrite($Handle,'""=>""),');

 

}else{

fwrite($Handle,  '"'.$keys.'"=>"'.$values.'",'); }

} fwrite($Handle,'""=>""),');

}else{fwrite($Handle,  '"'.$key.'"=>"'.$value.'",');}

}

fwrite($Handle,'""=>""),');

 

}

//$total += $_POST['shipping'];

fwrite($Handle,'"total"=>"'.$total.'");');

  fwrite($Handle,'

 

');

fwrite($Handle,'$detail = array(');

foreach($_POST as $k=>$v){

if(is_array($v)){

fwrite($Handle,'array(');

foreach($v as $key=>$value){

 

if(is_array($value)){

fwrite($Handle,'array(');

foreach($value as $keys=>$values){

fwrite($Handle,  '"'.$keys.'"=>"'.$values.'",');

}

fwrite($Handle,')');

}else{fwrite($Handle,  '"'.$key.'"=>"'.$value.'",');}

}

fwrite($Handle,')');

}else{

fwrite($Handle,  '"'.$k.'"=>"'.$v.'",');

}

}

fwrite($Handle,'""=>"");');

  fwrite($Handle,'

 

');

fwrite($Handle,'$paypal = array(');

foreach($paypal as $k=>$v){

if(is_array($v)){

fwrite($Handle,'array(');

foreach($v as $key=>$value){

 

if(is_array($value)){

fwrite($Handle,'array(');

foreach($value as $keys=>$values){

fwrite($Handle,  '"'.$keys.'"=>"'.$values.'",');

}

fwrite($Handle,')');

}else{fwrite($Handle,  '"'.$key.'"=>"'.$value.'",');}

}

fwrite($Handle,')');

}else{

fwrite($Handle,  '"'.$k.'"=>"'.$v.'",');

}

}

fwrite($Handle,'""=>"");');

 

fwrite($Handle,'

 

');

 

fwrite($Handle,'$shipping = "'.$shipping.'";

');

fwrite($Handle,'$subtotal = "'.$total.'";

');

$totals = $total+$shipping;

fwrite($Handle,'$totals = "'.$totals.'";

');

fclose($Handle);

 

 

$smarty->assign('filename',$filename);

$smarty->assign('shipping',$shipping);

$smarty->assign('paypal',$paypal);

//print_r($paypal);

$smarty->display('paypal.tpl');

}else{

$smarty->assign('total',$total+$shipping);

$smarty->assign('itemsInBox',$count);

$smarty->assign('cartBox',$cartBox);

$smarty->assign('shipping',$shipping);

$style = $db->select("SELECT * FROM styles WHERE `name`='default'");

$smarty->assign('style',$style);

$smarty->display($t);

}

 

?>

 

 

 

 

thanks,

 

Matt

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.