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
@GustavoNapa
GustavoNapa / functions.php
Created November 18, 2022 18:39
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');
}
}
@GustavoNapa
GustavoNapa / Mostrar aviso de valor minimo em loja Woocommerce function.php
Created September 2, 2021 16:26
Mostrar aviso de valor minimo em loja Woocommerce em condições especificas
if(is_user_logged_in()){
if(WC()->customer->get_state() == "RJ" || (WC()->customer->get_state() == "SP" && WC()->customer->get_city() == "São Paulo")){
if( $total <= $minimum_cart_total ) {
$saldo = $minimum_cart_total - $total;
$saldo_dec = number_format((float)$saldo, 2, ',', '');
$singular = '<br />Falta <strong>R$ %s</strong> para atingir o valor mínimo.</div>';
$plural = '<br />Faltam <strong>R$ %s</strong> para atingir o valor mínimo.</div>';
if ( $saldo > 1 || $saldo < 1 ) {
$msg = $plural;
} else {
@GustavoNapa
GustavoNapa / Fixar menu em site Wordpress.css
Last active December 22, 2023 17:21
Fixar menu em site Wordpress
#site-header.navbar-fixed-top{
display: block;
}
.navbar-fixed-top{
position: fixed!important;
z-index: 998;
background: #FFF;
top: 0;
left: 0;