Last updated on October 10th, 2023 at 09:13 am
This quick workaround allows you to avoid buying some expensive add-ons.
This post contains affiliate links. We may earn a commission if you purchase an item through our links. It costs you nothing and helps us to fund this blog. Please see our Affiliate Disclosure & Notification for details.
WooCommerce is one of the most popular eCommerce platforms in use today. The platform consists of a free WordPress plugin that includes the core. WooCommerce makes their money by selling extensions that add functionality to the free core.
The Core Does A Lot for Free
Ever since I started using and configuring WooCommerce for my own web store and my clients, I’ve been amazed at all the great features that come with it at no cost. You can sell unlimited products, variable products, downloadable products, virtual products – you name it.
Connecting your site to Jetpack and WordPress.com gives you access to live shipping rates in the US & Canada (UPDATE March 1st, 2019: The live shipping rates are no longer a free service but you can buy the official USPS Shipping Method here). You can also purchase and print shipping labels for orders right within the back end of your store and you actually save money because WooCommerce gets commercial shipping rates instead of retail.
…But it Misses Some Basics
As much as WooCommerce does for free, there are some seemingly simple things it does not do without buying an extension.
One of the limitations is for free shipping options. While WooCommerce does offer a free shipping setting, it applies to an entire order. If you have a single item in your store that offers free shipping, a customer will be offered the free shipping method for their entire order even if it contains other items that should not be shipped for free.
Doesn’t make much sense, does it? Fortunately, there’s a popular workaround: configure items for free shipping as virtual items instead of simple items. Since virtual items aren’t tangible, WooCommerce skips them in the order when calculating shipping. In effect, you get a free shipping item.
For 90% of online stores, this workaround is adequate. But I recently had a client who needed a bit more.
Shipping Addresses for Virtual Products
This client sold virtual products (downloadable software), but their sales department was required to mail out thank you cards to all customers including ones who bought virtual items. WooCommerce doesn’t collect a shipping address for virtual items and cannot be natively configured to do so.
There is an extension called Per Product Shipping by WooCommerce but it costs $79/yr. and the client wasn’t willing to pay that for what seemed to be a simple request.
In addition to that, the client required the new order emails to display the shipping address for all orders because these emails were used by the sales department who wouldn’t have access to the back end of the site. WooCommerce also doesn’t offer this function.
A 2-Step Solution
Step 1: Force WooCommerce to collect a shipping address on every order
The first part of my solution was to force WooCommerce to collect a shipping address for every order regardless of what the product was. Fortunately, this part can be done with a simple line of code:
add_filter( 'woocommerce_cart_needs_shipping_address', '__return_true', 50 );
This code should be placed in your child theme’s functions.php file. Alternatively, we’ve made a little plugin that does it for you that you can download for free on the CGS Computers Cyber Store.
Step 2: Force WooCommerce to display a shipping address on every new order email
The second step, which takes a tiny bit more energy, is to edit the WooCommerce email address template to ensure that the shipping address is always displayed in the order emails.
FTP into your web server (or use CPanel) and navigate through your website’s directory structure to /wp-content/plugins/woocommerce/templates/emails/. In this folder, you’ll find a file called email-addresses.php. Place a copy of this file into your child theme’s /woocommerce/emails/ folder. There’s a good chance you’ll have to create this folder unless you’ve already modified the WooCommerce email templates.
Once you’ve placed the email-addresses.php file in there you’ll need to modify it. Search for this line:
<?php if ( ! wc_ship_to_billing_address_only() && $order->needs_shipping_address() && $shipping ) : ?>
and replace it with this:
<?php if ( ! wc_ship_to_billing_address_only() && $shipping ) : ?>
Once you’ve made those changes, every new order email will contain both a shipping and billing address.
While WooCommerce includes a ton of useful features out of the box, the reality is that some things which seem to be pretty basic are sometimes missing. But frequently, with just a tiny bit of code, you can get the features you want.