One of the extensions that I love working with at WooThemes is the Subscriptions extension for WooCommerce. It's probably the most complex extension we have which can make troubleshooting issues challenging but that's offset because the developer also has the best documentation bar none.
The number of possibilities with Subscriptions are really endless. One of my favorite examples is HDPiano.com which sells virtual memberships to learn how to play piano. There's also plenty of users who sell tangible products each month. I just ran into a user who creates fancy shipping labels in Photoshop and uses those labels to ship her products.
The only problem in her case was that she creates the shipping label before the new order comes in so she needed a way to be notified of a customer changing their address before the actual order came in. This is where some of those awesome WooCommerce hooks come in.
Address Change Hook
In this case I'm going to be using the
woocommerce_customer_save_address action and add some additional functionality when the user changes their address on the My Account page.
I’m including the plugin for you to look at the code but you can also go the plugins home page and download it, extract the zip file, and upload the folder to your
/wp-content/plugins/ directory of your site.
In this case I just get all of the user data using the really useful
get_currentuserinfo() function and then get the customers address using the
WC_Customer class. Then send all of the information using the
wp_mail function. You might notice that I didn't add any filters in this plugin and I wrote the address in a standard US style. That's because this is a really quick snippet. If I wanted this to be more modular for the future I would add extra filters to accommodate these needs.
So what does it look like at the end? Why a simple email in your inbox.
While we don't offer customization support at WooThemes there is a lot of value in occasionally doing customizations like this. They are opportunities to dig into the code and learn a bit more about our huge WC system while helping a customer at the same time. And then if you can make the information publicly available (like this blog post) then it's indexable for future users. Win win in my opinion.