The idea of this method came to me when I was in a financially-dependent situation. At that time I was a student and had to really think of what was necessary and what was not. Before I started working as a teacher, my parents were supporting me, so I pretty much had to report and justify all my spending that was not an essential food. This type of discipline helped me to develop this funny method I am about to present. Nowadays, it is not only a financially beneficial strategy, but also has an environmental impact.
The method is based on the fact that there are Wants and Needs. It relies on tricking the desire to shop. When you are at the store, put everything you want in a cart. When you are done, start taking the items that have the least usefulness or actual value (in a grocery store, it can be those sugar/fat-infused snacks that you did not mean to buy this time) out. If you are shopping for some household items, do the same about the things you did not mean to buy before you saw them. Put them in the cart, satisfy your desire to appropriate something new, put it away. The thing is that if you purchase something you momentarily wanted and bring it home, you will feel the pleasure of owning it for a couple of hours before it blends in with the routine environment. If you are in doubts about an item, just wait a month before you commit to purchasing it (who knows, maybe there will be even a better option available, however, I suspect you will not remember about the item you wanted so much at that point).
Concerning an online shopping, the problem simplifies a lot because you do not get exposed to the numerous marketing traps, you are not pressured to make decisions on a spot, and you can always go check what you currently own not to buy some resembling items. The implementation of my method is the same. Go through the whole chain of events, but close your browser just before you go to checkout. And go rewind.
I am convinced that this approach helps to stimulate the pleasure centers and keep your money for the more thought-of purchases and investments. This trick also allows to maintain the apartments and environment cleaner because majority of stuff that is purchased impulsively first sits on some surface at home and afterwards ends up in the landfills.