The solution to this problem is to treat your young children in the same way that you would train the family dog, that is, you must exert strong discipline and do it immediately. It’s not good enough to threaten them with retribution when you get home, because their still-forming brains won’t connect the crime with the punishment.
My simple method works as follows: Go shopping when the supermarket is relatively deserted (you probably do that anyway to avoid embarrassment); as soon as a tantrum erupts, rush the child to the frozen-foods section and bundle him or her into one of those glass-fronted freezers and lean against the door for about five minutes (or as long as required—repeat offenders may need quite long periods of internment). On emergence, you’ll be pleasantly surprised at how quiet and composed your little shopper has become; in fact, he should be completely “chilled out”. If he looks like playing up later on, the merest mention of: “I wonder if we need any ice-cream…” should settle him right down again.