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 April 1, 2021 19:54
[WooCommerce] Moving cart calculator to the top of the cart collaterals
<?php
/**
* Moving cart calculator to the top of the cart collaterals
*/
add_filter( 'woocommerce_shipping_show_shipping_calculator', '__return_false' );
add_action( 'woocommerce_cart_totals_before_shipping', function(){
$packages = WC()->shipping()->get_packages();
$first_package = array_shift( $packages );
$formatted_destination = WC()->countries->get_formatted_address( $first_package['destination'], ', ' );
@luiseduardobraschi
luiseduardobraschi / functions.php
Last active April 23, 2021 18:19
Exibir dados do Extra Checkout Fields/Brazilian Market na página de pedido do Dokan
<?php
add_filter( 'woocommerce_order_formatted_shipping_address', function( $address, $order ){
if( $parent_order_id = $order->get_parent_id() ){
$order = wc_get_order( $parent_order_id );
}
$address['number'] = $order->get_meta( '_shipping_number' );
$address['neighborhood'] = $order->get_meta( '_shipping_neighborhood' );
@luiseduardobraschi
luiseduardobraschi / functions.php
Created June 9, 2021 20:05
Exibir campo de CPF nos pedidos do WCFM no painel do vendedor
<?php
add_action( 'wcfm_order_details_after_shipping_address', function( $order ){
$cpf = $order->get_meta( '_billing_cpf' );
?>
<div><strong>CPF:</strong> <?php echo esc_html( $cpf ); ?></div>
<?php
} );
@luiseduardobraschi
luiseduardobraschi / Cotação retornada pela API.php
Last active November 10, 2021 14:53
Scripts para testar os métodos no carrinho
<?php
add_action( 'arti_me_shipping_debug', function( $debug_message, $raw_message ){
if( is_array( $raw_message ) ) {
arti_mpme_show_messages_in_cart( array_column( $raw_message, 'custom_price', 'name' ) );
}
}, 10, 2 );
@luiseduardobraschi
luiseduardobraschi / functions.php
Created August 18, 2021 23:35
Permitir que etiquetas sejam geradas e status customizados.
<?php
// Adicionar status permitido para gerar etiquetas.
add_filter( 'arti_me_labels_generation_allowed_statuses', function( $statuses ){
$statuses[] = 'id_do_seu_status';
// $statuses[] = 'id_de_outro_status';
return $statuses;
@luiseduardobraschi
luiseduardobraschi / functions.php
Created August 19, 2021 00:21
Desabilitar ME por produto no Dokan
<?php
function arti_mpme_custom_disable_me_shipping_field(){
global $post;
$me_disabled = get_post_meta( $post->ID, '_me_product_disabled', true );
?>
<div class="dokan-form-group">
<input id="_me_product_disabled" name="_me_product_disabled" value="yes" type="checkbox"<?php checked( $me_disabled, 'yes' ); ?>>
@luiseduardobraschi
luiseduardobraschi / functions.php
Created August 30, 2021 21:13
[WCBR] Resposta post WooCommerce Brasil - 4342857705782162
<?php
function wcbr_create_lottery_numbers( $order_id ){
$order = wc_get_order( $order_id );
$items = $order->get_items();
$lucky_product_id = 28;
foreach( $items as $item_id => $item ) {
@luiseduardobraschi
luiseduardobraschi / .htaccess
Last active March 11, 2023 09:58
.htaccess - Load image from WooCommerce (WordPress, actually) production site if image not found in test env.
# You must place it above the "# BEGIN WordPress" comment.
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} ^/wp-content/uploads/[^\/]*/.*$
RewriteCond %{REQUEST_FILENAME} !-f
# Just change the URL to your liking.
RewriteRule ^(.*)$ https://www.production-site.com/wp-content/uploads/$1 [L]
</IfModule>
@luiseduardobraschi
luiseduardobraschi / functions.php
Last active May 28, 2023 00:57
[Fórum WP] PIX Pagar.me não copia código.
<?php
add_action( 'wp_enqueue_scripts', function(){
$is_pix_payment_page = function(){
global $wp;
//Page is view order or order received?
if( !isset($wp->query_vars['order-received']) && !isset($wp->query_vars['view-order']) )
return;
@luiseduardobraschi
luiseduardobraschi / functions.php
Created May 28, 2023 00:59
[WC Correios] Corrige o valor declarado para o valor atual.
<?php
// Valor declarado.
add_filter( 'woocommerce_correios_shipping_args', function( $args ){
if( 24 >= $args['nVlValorDeclarado'] ){
$args['nVlValorDeclarado'] = 0;
}
return $args;