Skip to content

Instantly share code, notes, and snippets.

View luiseduardobraschi's full-sized avatar
🤓
Updating knowledgebase...

Luis Braschi luiseduardobraschi

🤓
Updating knowledgebase...
View GitHub Profile
@luiseduardobraschi
luiseduardobraschi / package-rates.php
Created March 27, 2018 23:11
Change Melhor Envio shipping methods labels.
<?php
function test_methods_array(){
return [
'wpmelhorenvio_Correios_PAC' => 'Encomenda normal',
'wpmelhorenvio_Correios_EXPRESSO' => 'Encomenda expressa',
'wpmelhorenvio_JadLog_.Com' => 'JadLog Bar',
'wpmelhorenvio_JadLog_.Package' => 'JadLog Foo',
];
@luiseduardobraschi
luiseduardobraschi / SublimeLinter.sublime-settings
Created April 14, 2018 20:49
Correcting the error "SublimeLinter: WARNING: phpcs cannot locate 'phpcs'" on Ubuntu 16.04
// SublimeLinter Settings - User
{
"paths":
{
"linux": ["~/.config/composer/vendor/bin"]
}
}
@luiseduardobraschi
luiseduardobraschi / functions.php
Created May 25, 2018 09:50
Show either Correios or flat rate shipping method based on cart total.
<?php
add_action('init', function(){
function hide_correios_shipping_methods($rates, $package) {
$correios_methods_list = array(
'correios-pac',
'correios-sedex',
'correios-sedex10-envelope',
'correios-sedex10-pacote',
A partir do painel de controle de sua conta, você pode ver suas <a href="%1$s">compras recentes</a>, gerenciar seus <a href="%2$s">endereços de entrega e cobrança</a>, e <a href="%3$s">edite sua senha e detalhes da conta</a>.
@luiseduardobraschi
luiseduardobraschi / readme.md
Last active October 8, 2018 05:48
[WP BR] Remove out of stock product URL and redirect single to home
@luiseduardobraschi
luiseduardobraschi / functions.php
Created October 12, 2018 01:07
Dias a mais para produtos sob encomenda.
<?php
add_filter('woocommerce_correios_shipping_additional_time', function($additional_time, $package){
$has_outofstock_item = false;
foreach( $package['contents'] as $item ) {
if ( 'onbackorder' === wc_get_product($item['product_id'])->get_stock_status() ){
$has_outofstock_item = true;
break;
@luiseduardobraschi
luiseduardobraschi / functions.php
Last active December 8, 2020 19:06
Remover o campo "sexo" do checkout do WooCommerce com Extra Checkout Fields for Brazil.
<?php
add_filter( 'woocommerce_billing_fields', function( $fields ){
unset( $fields['billing_sex'] );
return $fields;
});
@luiseduardobraschi
luiseduardobraschi / functions.php
Last active March 19, 2019 04:00
Change new user notification e-mail body.
<?php
add_filter( 'wp_new_user_notification_email', 'gist_change_new_user_message', 10, 3 );
function gist_change_new_user_message( $wp_new_user_notification_email, $user, $blogname ){
$wp_new_user_notification_email['message'] = "This is the new mail body.\r\n\r\n"";
return $wp_new_user_notification_email;
@luiseduardobraschi
luiseduardobraschi / functions.php
Last active April 4, 2019 15:56
Disable package splitting in Dokan Pro
<?php
remove_filter( 'woocommerce_cart_shipping_packages', 'dokan_custom_split_shipping_packages' );
remove_filter( 'woocommerce_shipping_package_name', 'dokan_change_shipping_pack_name' );
remove_action( 'woocommerce_checkout_create_order_shipping_item', 'dokan_add_shipping_pack_meta' );
add_filter( 'woocommerce_shipping_methods', function($methods){
unset( $methods['dokan_vendor_shipping'] );
return $methods;
}, 11 );
@luiseduardobraschi
luiseduardobraschi / functions.php
Created June 7, 2019 02:37
Allow coupon only for customers who already have placed orders.
<?php
add_filter('woocommerce_coupon_is_valid', 'wcbr_coupon_is_valid', 10, 2);
function wcbr_coupon_is_valid( $valid, $coupon ) {
global $woocommerce;
$customer = $woocommerce->customer;
if ( wc_get_customer_order_count( $customer->get_id() ) < 1 ) {