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 / 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 / readme.md
Last active October 8, 2018 05:48
[WP BR] Remove out of stock product URL and redirect single to home
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 / 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',
@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 / 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 / loop.php
Created March 8, 2018 05:39
Adding taxonomy filtering to a loop
<?php
$args = array(
'post_type' => 'cardapio',
'posts_per_page' => 999,
'orderby' => 'title',
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'cardapio_category',
'field' => 'term_id',
@luiseduardobraschi
luiseduardobraschi / toggle.js
Last active December 9, 2017 20:14
A bookmarklet to quickly toggle admin bar in WordPress .
javascript: (function() {
var htmlStyle = document.documentElement.style;
var adminBarStyle = document.getElementById('wpadminbar').style;
if(undefined == window.hasAdminBar){
window.hasAdminBar = true;
}
var cssText, display;
@luiseduardobraschi
luiseduardobraschi / .bashrc
Created May 26, 2017 08:52
My .bashrc setup.
source /opt/wp-completion.bash
export DEV=/var/www/html
export EDITOR=subl
export PS1="\[$(tput bold)\]\[\033[38;5;58m\]\u\[$(tput sgr0)\]\[\033[38;5;15m\]@\[$(tput sgr0)\]\[\033[38;5;58m\]\H\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;15m\] [\t] \w \\$\n> \[$(tput sgr0)\]"
# function to set terminal title
function set-title() {
if [[ -z "$ORIG" ]]; then
ORIG=$PS1
@luiseduardobraschi
luiseduardobraschi / ApplicationContext.cs
Created May 26, 2017 00:08
Friendship workflow using Entity Framework
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
namespace Test.Models {
public DbSet<Friendship> Friendships { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder) {
/* USER */
modelBuilder.Entity<User>().HasMany(u => u.Friends).WithMany();