Skip to content

Instantly share code, notes, and snippets.

View GustavoNapa's full-sized avatar
🏠
Working from home

Gustavo Souza GustavoNapa

🏠
Working from home
View GitHub Profile
@fernandoacosta
fernandoacosta / functions.php
Last active April 2, 2023 18:07
WooCommerce -- limitar venda em determinado CEP
<?php
add_filter( 'woocommerce_package_rates', 'wc_restrict_sales_by_postcode', 10, 2 );
function wc_restrict_sales_by_postcode( $rates, $package ) {
$cep = WC()->customer->get_shipping_postcode();
$cep = preg_replace( "/[^0-9]/", "",$cep );
if ( '95555000' !== $cep ) {
$rates = array();
}
return $rates;