Notify Admin of Customer Address Change in WooCommerce

woocommerce banner

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 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.

End Result

Changed Address Email

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.

20 thoughts on “Notify Admin of Customer Address Change in WooCommerce

  1. Hello Sir,

    Thanks for the nice snippet, however the code is wrong.

    You need to get the user data from $user_id provided within a hook.

    Accessing global $current_user variable is wrong – in case admin changed some other user, he’d be notitifed about his own address.

    Moreover you should do the same for the $woocommerce functions used within the patricks_get_formatted_shipping_address.


  2. Just a heads up.

    I’ve checked the hook source and the $current_user global is used properly.

    I expected this hook to be fired on the admin edit page as well, which caused the confusion – you were right in here.

    Anyway the $user_id is not passed without a purpose – it should be used in spite of the global variable.

    • Glad that the hook fires at the right time. Using the global $current_user && get_currentuserinfo() is actually something you can find in the WordPress Codex so it should be fine to use. No sense using the $user_id and calling a less efficient function.

      • The function is going to be as much efficient as it’s been. It should also be a bit faster (due to lack of access to the global) nonetheless I’m not sure why the parameter is there.

  3. There is no plugin found at mentioned link.

  4. Thiri, You need to actually click on the link in the copy, not the ‘Plugins’ link in the header menu.

  5. Hey Patrick,

    Thanks for this information. Unfortunately for me, the mail i receive contains no address information. After the message “New shipping address” it’s blank. Username, Email, First name and last name works fine.

    Any thoughts? I’m working with Woocommerce 2.2.10.

    Any help will be appreciated.

  6. I’m very new to WordPress, but I absolutely need this feature ! Do I simply copy the .php file into my theme folder ? Thanks !

  7. This plugin is letting me know that a customer has changed their address, but is not sending me the new address.

  8. Hi Patrick,

    Thanks for the code snippet, but in email its showing wrong shipping address (Older one) and not the one which i am updating from shipping form on front end, do you know whats the issue ?

  9. Found some workaround by using $_POST[‘shipping_address_1’] instead of $woocommerce->customer->get_shipping_address() , and problem is solved, but i think this is not the right way, can you suggest something ?

  10. Hi Patrick,
    Nice plugin!
    I have a small problem though: the “New shipping address” in the email is not the new one, but the old one.
    Any idea on how to solve that?

  11. For some reason I am getting the notifications, but the address in the email is still the original un-edited address — if I update the address a second time, the first change appears in the email.

    is there a way to send me an email with the updated address instead of the original?

    also, is there a way to automatically update the customers order with the new address in the system without having to manually update the order from the admin edit order screen?

  12. This works fine for me but it’s sending the old address on change – not new one.

  13. hi Patrick

    great work, very handy.

    I’ve noticed this however doesn’t seem to work if an existing customer is buying something and changes their shipping address ( in the checkout process).

  14. hi Patrick

    great work, very handy.

    I’ve noticed this however doesn’t seem to work if an existing customer is buying something and changes their shipping address ( in the checkout process)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.