No, law does not demand that. You have to accept it to settle existing debt but that's it. For new customers you can demand any payment method you want. If they don't like it they are free to not form a contract. A cashless restaurant would be legal. They are just rare because of customer preference. But just look at online shops: they generally don't allow you to pay cash.
As I said, this law does not mean that you have to accept cash for every transaction. It is often repeated but that does not make it true. Requiring a specific form of payment is well within the freedom of contract.
And Nachname is not offered by every shop, probably not even the majority. If it's offered the usually for a steep surcharge. And while we are at it: Try paying your car tax in cash to the government and you will find it to be absolutely impossible.