It’s Impossible to Block PO Boxes in Shopify
I am a huge advocate of WordPress and Woocommerce, so right up front I’ll let you know of said bias. But that doesn’t mean you should take the following with anything less than a dump truck’s worth of salt.
The problem with Shopify, is that it’s a closed system.
Ignore the fact that as a developer, we have to learn a completely new language to work with Shopify. Ignore the AJAX backend interface which often takes many seconds to load, or doesn’t load at all.
The biggest issue I’ve run into as of late is that Shopify doesn’t allow you to customize the checkout process. So, say you don’t ship to PO Boxes…you cannot stop customers from using a PO Box as an address. It is impossible.
There are three plugins out there that claim to do this.
Validar.io
This Shopify add-on — which costs $0.035 / order — claims to disallow PO Boxes, but there are two big drawbacks:
- It doesn’t “kick in” until after the customer has already made their purchase. They get no notification until after the process is complete. At that point, they get this modal window:
- At this point, the customer can click “Update address”…but they can also click “Use this address,” in which case the order goes through and now shop owners have to deal with it manually.
To their credit, it’s Shopify’s fault, not the plugin developer. Because, as stated before, it’s impossible to truly do this. They do have excellent support, though, so props to that.
Another add-on, plainly named Shipping Address Validator, works pretty much the same way, but I haven’t been able to get in touch with support and, at $0.04 / per order, would therefore be inferior in all ways to Validar’s offering.
Mighty PO Box Blocker
This plugin — which costs $9.85 / month — does a little better job in my opinion.
It adds a new shipping method that looks like this:

The problem here?
- People can still checkout, and now instead of paying the typical $9 shipping fee, they’re skipping shipping fees altogether.
- So now shop owners not only have to manually deal with the address change, they need to figure out how to charge the appropriate shipping fee after the fact.
Blocking PO Boxes in Woocommerce
Well, it’s easy. And it can be free.
If you’re a developer, or feel comfortable editing your (child) theme, Woocommerce provides this code to do so.
Plenty of other developers have also shared different variations of this code as well, so if you want to allow PO Boxes for billing addresses but not for shipping, that’s possible.
The reason it is possible with Woocommerce is that Woo is built as a plugin for WordPress, and WordPress is open source. With the right developer, you can do anything with Woocommerce. With Shopify, you’re stuck with what their system allows.
I’ll add my own code below for those interested, modified from this Stackoverflow post. Because, unlike with Shopify, when you search for how to do something with Woocommerce, you’ll typically find dozens, if not hundreds, of free solutions created by developers like myself who know how superior open source is.
/**
* Prevent PO box shipping - clicknathan.com
*/
add_action('woocommerce_after_checkout_validation', 'deny_pobox_postcode');
function deny_pobox_postcode( $posted ) {
global $woocommerce;
$address = ( isset( $posted['shipping_address_1'] ) ) ? $posted['shipping_address_1'] : $posted['billing_address_1'];
$postcode = ( isset( $posted['shipping_postcode'] ) ) ? $posted['shipping_postcode'] : $posted['billing_postcode'];
$replace = array(" ", ".", ",");
$address = strtolower( str_replace( $replace, '', $address ) );
$postcode = strtolower( str_replace( $replace, '', $postcode ) );
if ( strstr( $address, 'pobox' ) || strstr( $postcode, 'pobox' ) ) {
wc_add_notice( sprintf( __( "Sorry, we cannot ship to PO BOX addresses.") ) ,'error' );
}
}
Up Next: Isotope with Masonry Layout Broken / Not Lining Up (and How to Fix It!)