S.B.
Your son sounds like a very smart little one and it's my guess he knows that he gets you worked up and can wear you down. So, that's the dynamic you have to change.
He knows that pitching a fit gets you upset and gets him what he wants.
I would cut out McDonald's and the treats BEFORE shopping and perhaps use it as incentive to behave in the store. If he doesn't, no treat, zero, nada.
And, when he pitches a fit to get out of the cart, simply look him in the eye and tell him you can't let him out because he will run away.
I hate to say it, but you have to be firm with him instead of trying to coax him to do what you want. It won't work that way.
I would start out with a list of just a few items. Tell him in the car, before you get him out that you are going into the store. He will sit in the cart and he will be a good boy and be nice until you are done shopping.
Then, in the store, if he throws a fit, tell him he is not acting like a nice little boy and he is NOT getting out of the cart. If he begs for a toy just ignore it and move on with getting your few items.
People in stores don't like hearing kids throw fits, but seriously, most of them are parents and they can see that you're pregnant with a loud little boy in the cart. Just calmly continue to tell him, don't care who hears it, that he is not acting like a nice boy. He is not getting out to run around and no toys.
Get your things, pay for them, smile at the clerk and wish them a nice day and go. Do not let your kid see you get flustered. That's what he's banking on. That's the reaction he's looking for. Don't give it to him. When you get him in the car, on the way home you can say, "Mommy told you that you had to stay in the cart in the store because you run away. Mommy asked you to be quiet in the store. You were not quiet. That wasn't very nice. Next time we go, I need you to be quiet and not yell and scream."
No stopping off for treats, just go straight home and give him a time out for acting up in the store. Ask him to say he's sorry and ask him if he thinks next time he will try harder to behave.
Keep your list short, keep your statements to him brief and calm.
Try this a few times without backing down.
I have a friend that didn't take her son to a restaurant, a movie, a museum, a library, until after he started kindergarten. She said she knew he wouldn't behave so why try? I am of the opinion that little kids don't know how to behave in public if you don't take them and teach them how to behave. They don't just magically wake up one day knowing how to act in a restaurant or a grocery store. They have to be taught.
The other thing you have to remember is that 2 year olds pretty much believe they are the center of the universe. That's the nature of the "beast", so to speak.
However, letting them continue to believe that without setting perameters does them no favors.
A two year old is NOT too young to understand that certain behaviors are not acceptable. You can get this turned around. He just needs to know that throwing fits, etc is not going to rattle you. He's not going to get his way and he's not going to get rewarded just to hush him up.
Hang in there!
Best wishes!