It uses the barcode - how would it know the difference between a kilo of gold, and a kilo of no-frills potatoes otherwise?
You swipe with a barcode putting the food in you trolley, when you pay you just go to the a special checkout and the trolley is weighed to verify that the contents is correct..