I got stuck, my objective was to get the ProductID, hidden inside the $_SESSION[‘cart’]
and then use those ID in an sql query to compute the sum
here’s my code
public function getProductID(){
$keys = array_keys($_SESSION['cart']);
return $keys;
}
public function getShippingFee(){
$ids = $this->getProductID();
foreach($ids as $id){
$query = mysql_query("SELECT * FROM deliverycharges WHERE ProductID = $id");
$row = mysql_fetch_assoct($query);
$sum = $row['Cost'] + $row['Tax'];
return $sum;
}
}
the second function that I pasted is wrong, I have done several type of looping and yet, I can’t get the real sum..shame on me
After you return, the function is exited, so you need to sum everything up at first and then return that after everything is summed up: