I started out babysitting these 2 girls when they were 3 and 4 yrs old. I learned that as with everything, if you are consistent they'll learn what is acceptable behavior and what is expected of them. This is with two kids who liked to "divide and conquer" - one would distract me while the other one ran off. What I did was to take a real hard stand. I said what I meant and I did what I said. It doesn't really matter what exactly you do, as long as you stick with it. You might have to repeat it 70 times but it does eventually sink in.
My sister has a kid 2 1/2 years old who HATES being in a cart. What she does is she takes him only on very short shopping trips to get just a few items. She is building his tolerance slowly. When she does a big shop, she gets a sitter.
My own son is 3 now, and I have always taken him with me on all my errands, so he is quite used to it. Mostly I had him sit in the cart; I let him choose whether he wants to start out up front in the seat or in the main part of the cart until it fills up with too much stuff.
Having worked in retail, I know how dangerous it can be if you are not cautious going around corners and the ends of aisles. The workers are under a lot of pressure and they are often pulling heavy loads too fast to stop if a child runs out in front of them. That is one good reason never to let your child go beyond the end of an aisle without you.
From infancy, I have tried to engage my son in the shopping experience. I talk to him about what we are selecting and why we are buying certain things and not buying other things. I talk to him about marketing and advertising. We make up games as we go- pretending we are in a jungle and searching for animals (they are everywhere, from Tony the Tiger on the cereal box to zebra print pajamas). We also engage in specialized "window shopping". I let him select a toy from the toy section to test out while we shop, and then we put it back before we leave. Occasionally I will put something in my cart that I say I want to think about and then put it back later, so he knows it's not just about him having to put something back. We stop and browse; looking at things he is interested in as well as items I want to look at. I just try to engage him as much as possible. It takes longer but it is a much happier day that way.
And I always bring a snack and a water bottle- for him and for me. And if I get too tired, we stop and rest. If he gets too tired, he lays down in the cart. We never do the, "you can have a treat if you're good" thing. He is always expected to "be good". At the end of the trip,he gets to choose a banana for him to eat- this is as close to a treat as we get, but it is not dependent on threats of not getting it for bad behavior. It is just the natural conclusion of our shopping trip that he looks forward to each time.
Best of luck with your situation- I hope you discover the solution that works well for you.