Take your children to the supermarket with you only when they are well fed, not tired, not ill, and are not thirsty! If you take them with you when they are tired, hungry, thirsty, or ill, you’re simply asking for trouble! In fact the best possible solution would be to do online shopping for groceries.
If you take them with you enlist their help looking for items, or counting things out etc. Keep them occupied and they shouldn’t run off so often. If they manage to get all the way round without running off, having a tantrum, etc offer them some kind of reward. It could be a snack in the coffee shop, a ride on a ride-on toy or an edible treat. Praise them whenever you catch them doing something you like, or behaving well.