People wonder if barcodes have descriptive information encoded in them like prices or product names. The answers is generally no. So how does the point of sales systems know the product that is scanning? Well, UPC barcodes (the ones that you see almost in any product at the supermarket) encode just a big number that uniquely identifies the product worldwide. When the cashier scans that product, the point of sale computer reads that number and then looks for the product details in a local database. That database can contain information like the product name, the price, available promotions, pictures, etc.
However, there are exceptions, like barcodes used in variable measure items which do include the price of the item.