Whoever started putting about this absolute weapons grade bollocks has so much to answer for. It's just fundamentally not true at all.
(tl;dr corporation taxes are assessed on profit, an additional donation expense would be cancelled out by a matching gain in revenue meaning no change in profit and therefore in tax paid. The supermarkets do this because it gives them a reputational benefit - it actually costs them money in admin and additional card fees.)