Last active
August 29, 2015 13:57
-
-
Save EranSch/9669753 to your computer and use it in GitHub Desktop.
Disallow a PO Box in WooCommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('woocommerce_after_checkout_validation', 'deny_pobox_postcode'); | |
function deny_pobox_postcode($posted) { | |
global $woocommerce; | |
$postcode = (isset($posted['shipping_address_1'])) ? $posted['shipping_address_1'] : $posted['billing_address_1']; | |
$postcode = strtolower(str_replace(' ', '', $postcode)); | |
if (strstr($postcode, 'pobox')) { | |
wc_add_notice( "Sorry, we don't ship to PO BOX addresses.", "error" ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment