My kids are 18 mos apart, so almost like twins.
I had to train them to hold hands, no matter what, for their safety. No matter what.
Like another poster that wrote about their dog's getting off leash and another poster responded with an article about an Emergency Come command, the one time you truly DO need to have your child right next to you may be the time they do not because they have trained you, instead of your training him.
Do not give in to their fits. You are raising a special snowflake if you do.
How I trained my kids in grocery stores--you know how there are free cookies or baked goods, or fruit for 25 cents for children to get? Or even a balloon giveaway from the store? or a token for the coupon machine at the store? And many parents get those at the first of the trip to distract the child?
Well, I held that as a reward for the end of the trip. And a few times, one child would receive the "prize" while the other did not. Oh, the howling in the car! but, not in the store!
Practice runs are a great idea. Put nothing perishable in your basket and be prepared to leave. no cajoling.
Engage your child to help you. "Should we get red or green apples?" "Which bread is it that daddy likes?" "Do you want red or blue box of cereal?" "How many juice boxes are in the box?" and so on...
That way, you are engaging in pre-math and educational conversations, teaching your son life skills of grocery shopping and decision making, he is paying attention, and although it may take longer,the pay off is so worth it!
My kids are teens now and I can divvy up a shopping list and meet them up front. We will have best price comparisons, the list followed just right, and they know how to put away the groceries at home.
It all began when they were babies in the car seat, and then the grocery seat, hearing me talk to them and engaging them.
It is work.
But, "this too, shall pass."
The fact that you are asking for help is a good sign--you are aware of a potential snowflake in training, and want to stop!
Bonus-
one store used to have small signs that said, "If cashier does not offer Deal of the Week to you, then you get it for free!" and once my kids could read, they learned to pay attention and more than once we received free items at the checkout counter. And almost every time the cashier would say, "No one else ever notices!"
Teaching a child to pay attention is a wonderful gift.
Good luck!