If a company prices a product erroneously, then (in the US) do they have to sell the product for that price, if someone buys it at that price?
Or are they allowed to correct the price and not sell for the erroneous price?
It will vary by jurisdiction. This is a complicated area of law, but usually an advertisement or a display of goods in a shop is not an "offer" (in the contract law sense of the term), but an invitation to treat (or "invitation to bargain" in the US).
The "offer" is the shopper saying "I'd like one of those please" or putting the goods on the band for the till. The "acceptance" is the checkout girl saying "that'll be ..."
A seller can correct their price, and they are not bound by an mistaken advertised priced. A sale is a contract, and there isn't a contract until the parties reach an agreement. A store being willing to sell (at some price) does not bind you to buy their item, and even if you intend to buy it, you have to overtly agree. In the usual store sale, they will post a notice by the item saying that they are sorry but the advertised price is wrong. At that point, since you know the price (or at the point of sale when you see the price), you can "cancel" the negotiations (sale), before a contract is formed (before you pay and they transfer ownership of the item).
Online sales generally are generally governed by a "terms of service" clause which allows them to cancel the sale in case of a pricing error. The reason why online sales are different is that the correct price is discovered after the sale, and you don't get notice saying "oops, that should be $50, not $5". If there is no TOS allowing them to cancel and refund, that would be a unilateral mistake, i.e. their fault, so they would be held to the price unless the discrepancy is "unconscionable" (basically, unreasonable to assume that the advertise price is correct).
20-708 item pricing
.