mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-04 12:22:24 +08:00
8 lines
365 B
Text
8 lines
365 B
Text
function wc_validate_zipcodes( $fields, $errors ) {
|
|
// Enter your zip codes in this array
|
|
$excluded_zips = array( '93301', '93304', '93305' );
|
|
if( in_array( $fields['shipping_postcode'], $excluded_zips ) ) {
|
|
$errors->add( 'validation', 'That zipcode is not allowed' );
|
|
}
|
|
}
|
|
add_action( 'woocommerce_after_checkout_validation', 'wc_validate_zipcodes', 10, 2 );
|