An article in the latest Sloan Management Review reports on some research that this also happens when people just imagine the self-image boosting behavior. If you plan to go on a diet next week or imagine yourself giving to charity, you are more likely to be self-indulgent. Yet another example of us fooling ourselves so that we can do whatever we want. In this case literally having our cake and eating it too.
They suggest some good marketing ideas. If a store puts donation bags or charity collection messages at the entrance of a store/web site, it would allow visitors to imagine giving or planning to give later and then they would buy more or higher margin stuff. It's a little hypocritical, but it would work.