Skip to content

Instantly share code, notes, and snippets.

View fernandoacosta's full-sized avatar

Fernando Acosta Fresinghelli fernandoacosta

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;
@fernandoacosta
fernandoacosta / functions.php
Created January 7, 2016 14:57
Remover formatação ao colar WordPress
<?php
/*
** Mudar <p> por <br /> no editor do fórum
*/
add_filter( 'tiny_mce_before_init', 'my_switch_tinymce_p_br' );
function my_switch_tinymce_p_br( $settings ) {
if ( ! is_admin() ) {
$settings['forced_root_block'] = false;
$settings['paste_as_text'] = true;
@fernandoacosta
fernandoacosta / functions.php
Last active July 11, 2020 01:27
Adicionar campo personalizado na busca de pedidos WooCommerce
<?php
/**
* @woo_custom_search
* @param string $search_fields
*/
function woo_custom_search( $search_fields ) {
$search_fields[] = 'Método de pagamento';
return $search_fields;
}
add_filter( 'woocommerce_shop_order_search_fields', 'woo_custom_search' );
@fernandoacosta
fernandoacosta / gist:c315da15b6f480665ef838cff25096bb
Created July 20, 2017 16:13
Dias adicionais - Condicional para 1 dia útil | Versão 1.0.
add_filter( 'wc_adpp_product_message', 'custom_wc_adpp_product_message', 10, 2 );
function custom_wc_adpp_product_message( $message, $days ) {
if ( 1 == $days ) {
$message = str_replace( 'dias', 'dia', $message );
}
return $message;
}
@fernandoacosta
fernandoacosta / functions.php
Last active January 29, 2020 17:04 — forked from SiR-DanieL/functions.php
Exibir produtos recentes quando nenhum produto for encontrado na busca
add_action( 'woocommerce_no_products_found', 'show_products_on_no_products_found', 20 );
function show_products_on_no_products_found() {
echo '<h2>' . __( 'Mas você pode gostar disso...', 'domain' ) . '</h2>';
echo do_shortcode( '[recent_products per_page="4"]' );
}
@fernandoacosta
fernandoacosta / functions.php
Last active April 27, 2018 02:58
Adicionar tags a um contato no mautic!
add_action( 'init', 'mautic_add_tag' );
function mautic_add_tag() {
$email = '[email protected]';
$api_data = AP_Mautic_Api::get_api_method_url( $email );
$url = $api_data['url'];
$method = $api_data['method'];
$body = array(
'email' => $email,
'tags' => 'produto-999, produto-5555, produto-11111, produto-0000',
@fernandoacosta
fernandoacosta / functions.php
Created May 27, 2021 00:41
extra triggers learndash
<?php
add_filter( 'learndash_notifications_email_content', function( $message, $notification_id ) {
if ( ! function_exists( 'WC' ) ) {
return $message;
}
// load the mailer class.
$mailer = WC()->mailer();
@fernandoacosta
fernandoacosta / vendasporanoeestado.php
Created May 24, 2022 12:08 — forked from emanweb/vendasporanoeestado.php
Relatório de vendas por ano e estado brasilero para WooCommerce
/**
* @snippet Relatorio de vendas por ano e estado brasileiro @ WooCommerce Admin
* @sourcecode https://gist.github.com/emanweb/3272d93d481e8c749edaa2cce2641b28
* @author Emanuel Costa
* @testedwith WooCommerce 6.3.1
* @inspiredby https://businessbloomer.com/?p=72853 (Rodolfo Melogli)
* @instructions Inclua esse código no functions.php to seu tema filho (child theme)
*/
// -----------------------