WooCommerce 3.8: Send a Notification Email When a Customer Changes Their Address

Envelope

Several years ago, I wrote a post, Send a Notification Email When a Woocommerce Customer Changes Their Address, that included a code snippet. Yesterday, I was contacted by a developer who tried to use the snippet and found it wasn’t triggered in his theme. I tested the snippet on my client’s site–he’s still using the Twenty Ten Theme–and found that it was triggered, but the email included the old address, not the updated address.

Note: I tested this code in PHP 7.3 and WooCommerce 4.0, and it still works.

Continue reading “WooCommerce 3.8: Send a Notification Email When a Customer Changes Their Address”

Send a Notification Email When a Woocommerce Customer Changes Their Address

Envelope

Note: There is a newer version of the code in this post tested with WordPress 5.2.4 and WooCommerce 3.8 in the post WooCommerce 3.8: Send a Notification Email When a Customer Changes Their Address.

I have a client who runs a subscription-based business on a WordPress site using WooCommerce. Since some of his subscriptions last a year or more, increasing the likelihood that a customer’s address might change, he wanted to be notified by email if the customer used the WooCommerce change-of-address form.

While it’s possible to add a custom email notification class so that the email notification will show up in WooCommerce -> Settings -> Emails, I really just needed something simple, and didn’t mind that the recipient email address would be hard-coded. I came up with the following code snippet, which does the trick in WordPress 4.6 and WooCommerce 2.6.4.

Continue reading “Send a Notification Email When a Woocommerce Customer Changes Their Address”