"how the system 'll read the price from the barcode"
You don't, unless it is a specific type of barcode that includes price-per-kg in the actual barcode data (and consumer unit barcodes don't normally do that)
Most barcodes you will meet hold only one piece of information: an Article Number which uniquely identifies a product as (say) 05012345678901 and to get the price for the item that number is used to index into a database which returns the full info:
AN 05012345678901
Description "tin of beans, Heinz, 400g"
Weight(kgs) 0.400
Price £1.23
Stock 1267
ReOrderAt 500
OrderFrom ...
So what you do for "loose weight" items is include a "loose weight" code in the data the DB returns and use that to calculate the price given the data from the weight scale.