WooCommerce: Hide a Shipping Method Based On User Role

Sometimes, it’s necessary to hide a shipping method in WooCommerce.

A client of mine offers local pickup only to a select group of customers. His business doesn’t have a showroom. The majority of his sales are on-line; however, he does sell to a few local businesses who prefer to pick up their orders in person. He’d been using a free-shipping coupon for those customers who picked up their orders at his shop, which works, but is more trouble for the customer than a custom user-role capability.

The example below shows how to hide the shipping method “Local Pickup” from all but users granted a specific user role capability using Vladimir Garagulya’s plugin User Role Editor to set and manage the custom user role capability.

Continue reading “WooCommerce: Hide a Shipping Method Based On User Role”

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”

Tax Exempt Customers for Woocommerce

Tax Exempt

I recently had a client who uses WordPress and Woocommerce for his e-commerce site ask me to come up with a method of making some customers tax exempt. He primarily sells to retail customers, but he has a number of resellers who use the site. The resellers should not pay sales tax, even though they reside in a state which does charge sales tax for retail customers.

I found some information on Woocommerce’s site which recommended extending the capabilities for the “customer” user role and adding an action to set the value of “set_is_vat_exempt” into the child theme’s functions.php in order to make some customers tax exempt. Unfortunately, the code snippet, which as of this writing hadn’t been updated since 2013, didn’t work, throwing a fatal PHP error on the test site and taking the entire site down.

Although, in the end, the fix was simple, it took a while for me to come up with a working solution, so I’d like to share it here, hopefully saving someone else the time and trouble of setting up tax exempt customers in Woocommerce. I’ve tested this approach using WordPress 5.3.2 and Woocommerce 4.0.

Continue reading “Tax Exempt Customers for Woocommerce”

Social Media Icons For Mobile Devices On Woocommerce’s Storefront Theme

Social Media Icons For Mobile Devices On Woocommerce Storefront

Woocommerce has kindly provided a Codex snippet to add social media icons to the Storefront theme. Their approach creates a very nice-looking social media icon menu; however, on displays less than 768 pixels in width, the Storefront theme hides the secondary navigation menu location used. Mobile devices using smaller displays end up with no social media icons.

The Storefront theme is a responsive theme, so it really should have the capability to display social media icons at all resolutions. I didn’t even notice there weren’t any until a client pointed it out to me.

Continue reading “Social Media Icons For Mobile Devices On Woocommerce’s Storefront Theme”

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”