I would say that, in general, denying a governmental service (like a planning permit or a zoning waiver) to a business solely because of political positions taken by the owners, which are unrelated to the business or service in question, and which are not otherwise illegal (like inciting the violent overthrow of the government), could be successfully challenged in court.
I would add that I think this is a good thing. As someone who takes unpopular political positions myself on occasion, I think a business or non-profit should only be denied permits for what they do in operating that business or non-profit, not who they give money to or what they say.
In terms of big box stores - yes they have been stopped, but not by laws saying "no Walmart" or whatever. You can't target a specific business. For example, one case I know of was an ordinance targeting businesses with over a certain number of square feet. A square foot limit on a single store is perfectly legitimate, and Walmart could still move in by putting up a mini-Wal Mart. They just have to obey the same rules as everyone else. Or some cities have minimum wage laws over the Federal and State level. And there have been cases of Walmart saying, "we don't operate like that -grant us an exemption if you want us". And the answer has been: "hey if you want to open in our town, live by our rules. No special treatment." If you want to target a firm for what they say start a consumer boycott. Nobody has an obligation to spend money with someone they don't like. But don't set the precedent of government retaliation for speech that is disapproved of.
There is not constitutional right to sell 2 gallon bottles of mayo. But if Alabama decided to ban Costco because they donated to the Obama campaign I'll bet most of us would not make that argument.
Look, I hate that corporations intervene in politics. But they way to stop that is to over the rulings that money is speech and corporations are people and ban corporations of donating to anything but charities that don't engage in politics and ban anyone (corporation or individual) from donating huge amounts of money to campaigns or political causes. Retaliating by government action against specific acts of free speech is a horrible precedent, because if it can be done to a corporation it can be done to an individual.
Free speech is for everyone, even horrible people advocating horrible things.