Created
June 21, 2019 14:24
-
-
Save plugin-republic/e5259a0822915b45f356a5f65bef9807 to your computer and use it in GitHub Desktop.
Prevent customers from certain zipcodes from checking out
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 | |
function pr_validate_zipcodes( $fields, $errors ) { | |
// Enter your zip codes in this array | |
$excluded_zips = array( '12345', '23456' ); | |
if( in_array( $fields['shipping_postcode'], $excluded_zips ) ) { | |
$errors->add( 'validation', 'That zipcode is not allowed' ); | |
} | |
} | |
add_action( 'woocommerce_after_checkout_validation', 'pr_validate_zipcodes', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment