Here's how to do it:
1. Equip the Confundus Charm: Make sure you have the Confundus Charm equipped by selecting it from your spell wheel.
2. Target the Customer: Aim your cursor at the customer you want to distract.
3. Cast the Charm: Press the button that corresponds to the Confundus Charm (usually "X" on most platforms).
Once you cast the Confundus Charm, the customer will be temporarily distracted and wander around the shop, giving you time to grab the sweets you need.
Important Note: The Confundus Charm only works on certain customers. You'll notice that some customers are highlighted with a blue glow when you aim your cursor at them. These are the ones who are susceptible to the charm.
Good luck!