The retail giant will pay out tens of millions to settle a class action suit accusing it of overcharging customers for some groceries.