This is increasingly difficult, at least in Western Europe, without it being a significant imposition. I've had several instances where, despite absolutely no signage or indication anywhere outside the business, inside the business, or on the menu, I've waited in a queue, ordered something, and only when I'm ready to pay been told that the, eg, coffee shop won't accept cash. I've also been to several restaurants, especially in London, where despite officially accepting cash, attempting to pay in cash will result in the staff returning and asking you not to if at all possible: it appears that the staff at those restaurants are not actually allowed to handle cash payments themselves, and have to have management handle them directly.
While it's not clear that these behaviours are legal, it does not appear that there is any enforcement.
In England at least, those behaviours are legal, without a doubt [0][1]
I'm not aware of a law that requires them to clearly sign post which payment methods they accept. I think there are various laws in other places in Europe though. I'm definitely all for that
They're taking on the risk of spoilage by not putting in any effort to make you aware before ordering - and hoping you'll just pay by card due to the sunk time cost. Shady but not illegal AFAIK.
I assume part of it is that if you accept any cash, you have most of the downsides without any of the upsides (e.g. not having to deposit cash at the bank).
Buy somewhere else (if humanly possible), and tell this to the vendor who doesn't want to accept cash.