At home, if our dd (same age) is playing up she gets a warning in my 'stern mummy voice'. If she doesn't stop we tell her to 'go away' (just out of the room we're in with door shut) because we don't want to be around her when she's doing.....
and we'll come and get her when we're ready.
After a couple of minutes we go and get her and she apologises then cuddles and friends again.
She screams when sent away but usually just the threat of it is enough to stop the bad behaviour.
In shops I try and hold her attention as much as possible, or have her attached somehow (buggy/trolley etc). She has run away before (giggling madly) and I gave her a very long and emotive talking to along the lines of how awful it would be if she lost mummy and someone stole her and she never saw mummy again and how sad and upset mummy was that she had run away and....
Just seeing that she had really upset me took the fun out of it for her I think.
She had a massive screaming fit in middle of M&S the other day, the full lying down on floor tantrum and have to say I just stood there and laughed cos she looked so funny, as did other people walking past (well, most people, the odd evil stare from some). Eventually she obviously felt a bit silly as she got up and came over to me for a cuddle.
I think if you lose your temper, they win, and at this age you can't let them win - they have to lose these battles, so keep cool!
Also lots and lots of praise for when she's being a good helper in the shop and holding my hand etc. Must admit to the odd sugar free lolly bought at the till 'because you've been such a good girl and not run away and stayed with mummy blah blah blah...'