Skip to content

Instantly share code, notes, and snippets.

@claudiosanches
Created November 14, 2015 00:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save claudiosanches/545c2acab4095a3ed4c8 to your computer and use it in GitHub Desktop.
Save claudiosanches/545c2acab4095a3ed4c8 to your computer and use it in GitHub Desktop.
Exemplo completo de desenvolvimento de plugin
<?php
/**
* Plugin Name: PAC Gratuito
* Plugin URI: https://claudiosmweb.com/woocommerce/woocommerce-deixar-o-metodo-de-entrega-pac-dos-correios-gratuito/
* Description: Deixa o valor do PAC do WooCommerce Correios sempre como gratuito.
* Author: Claudio Sanches
* Author URI: http://claudiosmweb.com/
* Version: 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Mostra apenas uma tela branca se algum retarda tentar acessar o arquivo diretamente.
}
function custom_woocommerce_correios_shipping_methods( $rates ) {
foreach ( $rates as $key => $rate ) {
if ( 'PAC' == $rate['id'] ) {
$rates[ $key ]['cost'] = 0;
break;
}
}
return $rates;
}
add_filter( 'woocommerce_correios_shipping_methods', 'custom_woocommerce_correios_shipping_methods' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment