Do you know any teenagers who could use a little extra cash once a week? :-)
Also, what time of day are you shopping? Mine typically do best on grocery trips fairly early in the morning....like before 10am.
Also, fewer trips to the store will save you some grief. For example, with the way our budget is set up I get my grocery money out in cash once a month. I make one huge trip (which might be worth getting someone to babysit for -- I typically leave mine home with their dad...or, if their dad has visitation, maybe shop while they're at his place?). I try to get a month's worth of all the non-perishibles and paper goods, check to see if we'll run out of anything in the next 30 days, such as ketchup, cooking oil, etc. and go ahead and get that too. I get 4 or 5 bottles of apple juice, 5 boxes of cereal, 3 jars of peanut butter, 5 loaves of bread (you can freeze them and pull a loaf out as you need it), etc.
You should also be able to get 2 weeks worth of some perishibles, dairy, fruit, etc.
This way, when I do have to make trips to the store with the it's just for a few items and we can get in and out quickly.
And, I gave up trying to confine mine in the cart for long. Since our trips are quick, I enlist their help. I've come home with weird brands, smashed bread, etc., but it's a small price to pay for a peaceful trip to the store. If you really have a "runner" on your hands, it might not work, but what I do is have them ride in the cart til I get to the first isle. I tell each kid an item on that isle to retrieve, then send them out. I tell them they need to get their item and come straight back to the cart. While they're running down the isle, I grab whatever else I need, then they come back, hop back into the cart, and we round the corner to the next isle, repeat the process... They'll get tired of it eventually, but if I can keep things moving quickly, we can make it from one end of Walmart to the other fairly peacefully (notice "fairly" -- peace is a relative term when preschoolers are concerned).
Another idea would be something that I read in the Parenting with Love & Logic book. You basically stage a training session. It will take some planning, but the results can be worth it. If you have a relative or good friend who's willing to help you out, have them meet you at the store, but don't let your kids know she's there. She'll wait outside while you go in as if it's a normal shopping trip. Before you get them out of the car, tell them the ground rules (staying in the cart, etc.) and how you expect them to behave, then say, "If getting groceries becomes too much trouble and not enough fun for me, something's going to happen..." Don't tell them what will happen!
Go about your shopping and when they begin misbehaving, stop the cart and say, "uh oh, looks like something's going to have to happen. Excuse me while I make this phone call." Give your friend a call and her job is to swoop in with another grocery cart, load the boys up and take them somewhere else. She could take them to your house, her house, or grab your keys and take them to your car, buckle them in and wait with them for you to get done. If she takes them somewhere, you'll have to work out how to move car seats, etc.
Anyway, according to the stories in the book, this little trick worked.
hope some of this helps!