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 / 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 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 / 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 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
Created March 29, 2021 17:27
Fix broken Query Monintor in WC Marketplace seller panel
<?php
add_action( 'wp_enqueue_scripts', function(){
wp_enqueue_style(
'query-monitor',
QueryMonitor::init()->plugin_url( "assets/query-monitor.css" ),
[],
QueryMonitor::init()->plugin_ver( "assets/query-monitor.css" )
);
}, PHP_INT_MAX );
@luiseduardobraschi
luiseduardobraschi / Referência de filtros Marketplace-Melhor Envio.md
Last active August 7, 2022 22:05
Referência de filtros Marketplace/Melhor Envio

Utilidades

add_filter( 'arti_mpme_show_messages_in_cart', '__return_true' );

Mostra mensagens de debug ("depuração") no carrinho para usuários administradores referentes ao cálculo do frete, como erros de configuração do vendedor e mensagens de retorno da API.

add_filter( 'arti_me_force_agency_list_update', '__return_true' );
@luiseduardobraschi
luiseduardobraschi / functions.php
Created February 26, 2021 11:47
[Dokan] Add support to multiple postcode ranges.
<?php
use WeDevs\DokanPro\Shipping\ShippingZone;
add_filter( 'dokan_vendor_shipping_is_available', function( $is_available, $package, $shipping ){
$seller_id = $package['seller_id'];
$destination_postcode = isset( $package['destination']['postcode'] ) ? $package['destination']['postcode'] : '';
$destination_postcode = wc_normalize_postcode( $destination_postcode );
if ( empty( $seller_id ) ) {
@luiseduardobraschi
luiseduardobraschi / functions.php
Last active August 19, 2022 08:06
Remove country and city fields from shipping calculator and disable "calculate shipping" toggle non-sense.
<?php
add_filter( 'woocommerce_shipping_calculator_enable_country', '__return_false' );
add_filter( 'woocommerce_shipping_calculator_enable_city', '__return_false' );
@luiseduardobraschi
luiseduardobraschi / functions.php
Last active June 1, 2020 10:41
Disable all Dokan Pro modules at once.
<?php
add_action('init', function(){
dokan_pro()->module->deactivate_modules(
[
'booking',
'color_scheme_customizer',
'elementor',
'export_import',
'follow_store',
@luiseduardobraschi
luiseduardobraschi / functions.php
Last active December 5, 2019 03:15
[WooCommerce BR] Woocommerce - show discount percentage
<?php
add_filter( 'woocommerce_sale_flash', function( $string, $post, $product ) {
$regular_price = (float) $product->get_regular_price();
$sale_price = (float) $product->get_price();
$discount = round( 100 - ( $sale_price / $regular_price * 100 ), 1 );
return sprintf( '<span class="onsale">%s%%</span>', $discount );