Do Not Allo PO Boxes
-
I cannot ship products to PO Boxes so I found this snippet to do that:
add_action('woocommerce_after_checkout_validation', 'deny_pobox_postcode'); function deny_pobox_postcode( $posted ) { global $woocommerce; $postcode = ( isset( $this->posted['shipping_postcode'] ) ) ? $this->posted['shipping_postcode'] : $this->posted['billing_postcode']; $postcode = strtolower(str_replace( ' ', '', $postcode )); if ( strstr( $postcode, 'pobox' ) ) { $woocommerce->add_error( "Sorry, we don't ship to PO BOX addresses." ); } }
This code comes from here: https://gist.github.com/2282666
The problem is, when I add this snippet to my theme’s function.php file, I get this fatal error: Using $this when not in object context in…
What am I doing wrong?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Do Not Allo PO Boxes’ is closed to new replies.