Skip to content

Instantly share code, notes, and snippets.

@GustavoNapa
Created November 18, 2022 18:39
Show Gist options
  • Save GustavoNapa/3644ecb92dcb642735143d278d16f474 to your computer and use it in GitHub Desktop.
Save GustavoNapa/3644ecb92dcb642735143d278d16f474 to your computer and use it in GitHub Desktop.
Basta adicionar ao arquivo functions.php
//Filtro para permitir vendas apenas para alguns cep's
add_action('woocommerce_checkout_process', 'wc_restrict_sales_by_postcode');
function wc_restrict_sales_by_postcode() {
$cep = $_POST['billing_postcode'];
$cep = preg_replace( "/[^0-9]/", "",$cep );
if ( $cep < 30000000 || $cep > 35000000 ) {
wc_add_notice(('Infelizmente ainda não atendemos na sua cidade CEP: '.$cep.'.'), 'error');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment