Step one: Before you leave, make sure the child is fed and dressed appropriately. Make sure you've given him enough attention this day. If you need to, read him a story to help him feel loved. Bring water, food, and other needed supplies if you are going to be out a long time.
Step two: Warn the child that you are going and tell him what your objective is so he doesn't expect you to buy him a lot of stuff.
Step three: When you are driving to your destination, tell him your expectations. Tell him the rules of the place you are going. Have him repeat them back. You can offer a reward for good behavior, but only if you think it is needed. Mostly, you should just expect the good behavior.
Step four: Tell the child that he can only come with you if he follows the rules. If he has a tantrum you will bring him home and go back later. Be prepared to follow through and leave your shopping cart if you need to. Do not tell them this if you can't follow through. They will stop believing you and test you more the next time. You must leave every time there is misbehavior, even if it is a fun place like a museum or swimming pool. You don't have to yell or get angry....leaving is enough to deter the behavior. Just be loving and firm. Tell him you are sorry he chose not to stay. You can even give him a hug and tell him you know he can do better the next time.
Step five: Compliment good behavior in the store. Give him a hug or a pat on the back when you are done. Praise him in front of others when you get home.
This method works every time. We have virtually eliminated tantrums and whining in the store, or misbehavior in restaurants. The key is consistancy, love, and following through. I hope it works for your children too!