Unfortunately for most people this happens much to often, and can quickly cause severe credit card debt. The Internet is riddled with ways to detour people from using their credit cards, like the classic freezing your credit card in a block of ice. I, on the other hand, have a more practical solution I call "Credit Card Defacing." If you are currently trying to pay off a credit card with revolving debt, take a sharpie and write something embarrassing like "I am an idiot for using this card", "emergency only", or "Don't let me buy this" in big letters on the front of the card. The next time you use the card, you will be scrutinized by the person behind the counter. They will probably laugh at you, creating an extra humility barrier between you and your purchases. In a true emergency situation, the graffiti will not hinder the use of the card. Although keeping a credit card for emergencies is ridiculous and unnecessary anyway. People should instead have an emergency savings account linked to a debit card, but that is their decision.
"Defacing your Credit Card" is a great deterrent that allows you to cater the card message to the severity of you spending habits. If you have a really big problem you could even try writing offensive stuff like "Screw You" on the card. If the cashier does not have the thickest of skin, he or she might not even do business with you.
Every time you feel the urge to buy something with that credit card, you will stop and ask yourself is it really worth having to deal with the clerk. That will ultimately help curb spending.