Thanks. I have just this minute got it working. Basically the same function I used for determining price of the cart items could be used for determining weight. All I needed to do was assign my DB with a field called weight and call that instead of price from the DB so my calculate weight function looks like this.
function calculate_weight($cart) { // sum total weight for all items in shopping cart global $weight; $weight = 0.0; if(is_array($cart)) { $conn = db_connect(); foreach($cart as $ItemCode => $qty) { $query = "select weight from products where ItemCode='$ItemCode'"; $result = mysql_query($query); if ($result) { $item_weight = mysql_result($result, 0, "weight"); $weight +=$item_weight*$qty; } } } return $weight; } By making $weight a global variable I then call that in my shipping function and set it's parameters: function calculate_shipping_cost($weight) { //shipping costs calc. less than 10KG is 15 more than 10KG currently 20. global $shipping; if ($weight <= "10000") $shipping = "15"; else $shipping = "20"; return $shipping; } I still don't fully understand why this works but am happy it does! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php