When DS was acting like that I just told him that I would never take him shopping again. He was old enough to understand what I was saying, and I tell him that if he's naughty then we're leaving. Straight out. I don't care if I leave groceries in the shopping trolley or whatever, I WILL walk out of there and just go straight home.
I second, third and fourth that, it really works. Sometimes you only have to do it once and they geddit.

Beside that, if you can get someone to watch him for an hour whilst you shop on your own it's so much easier and less rushed.