I don't see anything in your code that multiplies the product detail by the quantity in the shopping cart. If you have an item three times in the cart, is that item stored three times, or once with a quantity field? If the latter (which is certainly the way I'd do it), then you need to use that to multiply your figures.
ETA: perhaps something like this based on a quick search:
$totalProfit += ((float) $product->getData('profit')) * $item->getQty();