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”

Contact Form 7: Set the Default Value for Select Fields Using the URL

Contact Form 7 and Default Select from URL Variable

Contact Form 7 is my favorite contact form plugin for WordPress. Not only is it well-documented on the developer’s web site,  but it offers a plethora of valuable features that have made it my go-to contact form. One of those features is Contact Form 7’s ability to use variables in the URL ($_GET variables) to set the default value for email form fields.

Contact Form 7’s documentation explains in detail how to set the default value of text fields to $_GET variables passed in the URL; however, as of this writing, it doesn’t tell you that you can also set the default value of a select field by passing the value of the field in the URL.

Continue reading “Contact Form 7: Set the Default Value for Select Fields Using the URL”

Undefined Index: SCRIPT_NAME

Which PHP

A WordPress plugin on one of my client’s sites was filling up the error log with a PHP error “undefined index” for the server variable SCRIPT_NAME. The error persisted through a number of plugin updates. I found that I could work around it by editing the plugin’s code and substituting the server variable PHP_SELF instead of SCRIPT_NAME, but it was a hassle to modify the code for the plugin every time there was an update, and I wanted to find a permanent fix.

Continue reading “Undefined Index: SCRIPT_NAME”

Adblock Plus and the Paste Special Keyboard Shortcut

Adblock Plus

Ads on a lot of websites are out-of-control. My local newspaper’s web site is a good example. There are so many ads on the site that it takes an annoyingly long time to load, even on a 100+ megabits-per-second connection. Not only do the pages load slowly, but some of the ads’ behavior-expanding and contracting by themselves–moves the content on the page around so much that it’s difficult to read the text. I’ve had the ads cause Firefox to hang too, locking it up until the ads finish doing whatever they are trying to do. Then there are the sites with videos configured to auto-run…

I don’t see any way to remain sane without running some kind of ad blocker. I hate to do it, because I know many sites depend on the revenue generated by displaying ads to stay solvent, but without some kind of relief from all the ads, I’m not going to visit the sites anyway.

Adblock Plus comes to the rescue.

Continue reading “Adblock Plus and the Paste Special Keyboard Shortcut”

This Is Somewhat Embarrassing, Isn’t It?

Title Variable

It was not only embarrassing; it was puzzling.

I was contacted by a client whose site was returning the dreaded WordPress “this is somewhat embarrassing, isn’t it?” 404 not found error message whenever he tried to access some of his pages. The affected pages all included custom variables in the URL following pretty permalinks based on the post name.

Continue reading “This Is Somewhat Embarrassing, Isn’t It?”