Compare the price for the same amount, not the number on the price tag, and you'll never get confused.
The unit price formula
Unit price = amount paid ÷ total quantity × reference quantity. The common reference is 100 g for weight, 100 ml for volume and 1 for single items.
For example, two 500 g bags for 12,900 come to 1,000 g in total, so 1,290 per 100 g. One 300 g bag for 8,900 plus 3,000 shipping comes to about 3,967 per 100 g.
Common mistakes
Comparing without shipping. Online, shipping can change the unit price a lot
Mixing kg with g or L with ml and comparing as entered
Entering the quantity of a buy one get one (BOGO) deal as 1
Comparing weight with volume. Density differs, so they can't be compared
When buying large sizes
Large sizes usually have a lower unit price, but if it spoils or goes unused, the unit price rises by whatever you throw away. Look at the expiration date, your storage space and how much you pay at once.
If the store's shelf label shows a small "per 100 g" price, that's a good reference too. Online, you can check right away with DDD's Unit Price Calculator.