Any decent system will check the stock level at the point when payment is taken.
In any case, quirky website/coding issues shouldn't be the consumer's problem - if the merchant takes your money, it should be the merchant's problem finding the stock. At that point, a contract for the supply of goods and services is formed between buyer and seller. Inability of a merchant to get their website working properly shouldn't be an excuse to void contracts, otherwise most contracts won't be worth the paper they're figuratively written on.
As a consumer, I might not even know that the product is supposedly "out of stock" - I might not even have looked at the product page, but simply clicked on the "recommended for you" picture, then happily checked out, being none the wiser.