@gollum,
It really depends on the type of business you're talking about. Shops (or other businesses) that are open to the general public may not discriminate against any potential buyer. But there are certain shops that are
not, in fact, open to the general public. A discount club, for example, may require its shoppers to become members in order to be admitted to the store. Sam's Club, a Walmart subdivision, is one such enterprise. I can imagine a store being set up in which, in order to be served, one must first show a union membership card and become a member. There are shops for Federal government employees that require identification as a government worker. I can see no violation of law in such an arrangement.