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 March 28, 2024 06:19
Compatibilidade Dokan e Simulador de Frete para WooCommerce (Luiz Bills)
<?php
add_filter( 'wc_shipping_simulator_package_data', function( $package ){
if( $product_id = $_GET['product'] ?? $_POST['product_id'] ?? false ){
$package['seller_id'] = get_post_field( 'post_author', $product_id );
}
return $package;
@luiseduardobraschi
luiseduardobraschi / dynamic.php
Created March 26, 2024 21:59
Dynamic routing in Laravel
<?php
Route::match(
['get', 'post'],
'{controller}/{action?}/{params?}',
function ($controller, $action = 'index', $params = '') {
$params = explode('/', $params);
$methodParams = [];
foreach ($params as $key => $param) {
@luiseduardobraschi
luiseduardobraschi / class-wc-pagarme-api.php
Created March 15, 2024 04:43
Atualização de status plugin Pagar.me - Cláudio Sanches
<?php
/**
* Pagar.me API
*
* @package WooCommerce_Pagarme/API
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
@luiseduardobraschi
luiseduardobraschi / functions.php
Created March 15, 2024 04:39
[Fórum WP] Validação fingerprint postback
<?php
if( !class_exists( 'WCPagarmePixPayment\Pagarme\PagarmeApiV4' ) ){
return;
}
use WCPagarmePixPayment\Pagarme\PagarmeApiV4;
class ArtiPagarmeApi extends PagarmeApiV4 {
@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;
@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 / .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
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 / 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 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;