Hi all, I’m trying to do a header relocate but getting the following error. Though I cannot see what is wrong
Warning: Cannot modify header information - headers already sent by (output started at /htdocs/includes/shopping.cart.php:136) in /Volumes/Lacie 500GB External /htdocs/index.php on line 38
Please see below for shopping.cart.php…
<?php
class ShoppingCart {
protected $items = array();
protected $vatRate = 1.20;
public function is_empty(){
if(empty($this->items)):
return true;
else:
return false;
endif;
}
//Method for adding an item to the cart...
public function add_items($id, $info){
//Is it already in the cart?
if(isset($this->items[$id])):
//Call the update_item() method:
$this->update_item($id, $this->items[$id]['qty']+1);
else:
//Add the array of info...
$this->items[$id] = $info;
//Add the quantity...
$this->items[$id]['qty'] = 1;
endif;
}
public function update_item($id, $qty){
//Delete if quantity equals 0...
if($qty == 0):
$this->delete_items($id);
elseif(($qty > 0) && ($qty != $this->items[$id]['qty'])):
//Update the quantity...
$this->items[$id]['qty'] = $qty;
endif;
}
public function update($period){
foreach($this->items as $id=>$value):
$hireTime = mysql_query("SELECT * FROM pricing WHERE products_id = $id AND products_timeframe = $period");
$hire = mysql_fetch_assoc($hireTime);
$this->items[$id]['option'] = $hire['pricing_id'];
endforeach;
}
//Method for deleteing an item...
public function delete_items($id){
//Confirm this isn't in the cart...
if(isset($this->items[$id])): //Remove the item...
unset($this->items[$id]);
endif;
}
public function count_cart(){
//print_r($this->items);
$i = count($this->items);
return $i;
}
public function cart_total(){
foreach($this->items as $value):
$total += $value['price']*$value['qty'];
endforeach;
return $total;
}
function grand_total(){
foreach($this->items as $id=>$value):
$price = mysql_query(sprintf("SELECT products_price FROM pricing WHERE pricing_id = %s", $value['option']));
$cost = mysql_fetch_assoc($price);
$multi[] = $cost['products_price']*$value['qty'];
endforeach;
return number_format($total = array_sum($multi),2);
}
function get_hire_period($option){
$option = (int) $option;
$sql = mysql_query("SELECT products_timeframe FROM pricing WHERE pricing_id = $option");
$fetchFrame = mysql_fetch_assoc($sql);
$_SESSION['HIRE_PERIOD'] = $fetchFrame['products_timeframe'];
}
function vatRemove($vat){
$base = $vat/$this->vatRate;
return $base;
}
function delivery_price($delID){
$del = mysql_query(sprintf("SELECT shipping_cost FROM shipping WHERE id = %f", $delID));
$price = mysql_fetch_assoc($del);
return $price['shipping_cost'];
}
//Function to enter product details into application tables...
function enterApplication(){
//Insert main order details...
$application = mysql_query(sprintf("
INSERT INTO application_order
(customers_id, customers_name, customers_address, customers_telephone, customers_email,
coupon_code, last_modified, date_purchased, order_status, order_total, delivery_cost,
order_tax_rate, order_tax, ip_address)
VALUES('%f', '%s', '%s', '%s', '%s', '%s', now(), now(), '%f', '%f', '%f', '%s', '%f', '%s')",
$_SESSION['USERS_ID'], $_SESSION['USERS_FULL_NAME'], $_SESSION['USERS_ADDRESS'], $_SESSION['USERS_TELEPHONE'],
$_SESSION['USERS_EMAIL'], $_SESSION['COUPON_CODE'], '0', $this->grand_total(), $this->delivery_price($_SESSION['DELIVERY']),
$this->vatRate, $this->grand_total()-$this->vatRemove($this->grand_total()), $_SERVER['REMOTE_ADDR']
));
//Get the id of the application row...
$insertedID = mysql_insert_id();
//Insert products into application_products table
foreach($this->items as $id=>$value):
$price = mysql_query(sprintf("SELECT products_price, products_timeframe, products_price FROM pricing WHERE pricing_id = %s", $value['option']));
$cost = mysql_fetch_assoc($price);
$totalCost = $cost['products_price']*$value['qty'];
$insertProducts = mysql_query(sprintf("
INSERT INTO application_products
(products_id, products_name, products_price, products_qty, products_period, products_row_total,
products_vat_amount)
VALUES ('%f', '%s', '%f', '%f', '%f', '%f', '%f')",
$id, mysql_real_escape_string($value['name']), $cost['products_price'], $value['qty'],
$cost['products_timeframe'], $totalCost,
$totalCost-$this->vatRemove($totalCost)));
endforeach;
}
}
?>
I have tried removing the viewCart method but still does not make any difference
Any help is appreciated as always