Skip to content

Instantly share code, notes, and snippets.

View webdados's full-sized avatar

Marco Almeida webdados

View GitHub Profile
@webdados
webdados / shop_as_client_autocomplete_user_label.php
Created April 8, 2025 13:28
Change the label for the autocomplete user results no the Shop as Client for WooCommerce plugin
<?php
add_filter(
'shop_as_client_autocomplete_user_label',
function ( $label, $user_id, $display_name, $user_email ) {
// Get the user
$user = get_user( $user_id );
$name_to_display = html_entity_decode( $user->display_name, ENT_QUOTES, 'UTF-8' );
// Use same label but with $name_to_display as the name
return sprintf(
__( 'Cust. #%1$d: %2$s - %3$s', 'shop-as-client-pro' ),
@webdados
webdados / shop-as-client-fix-priority.php
Created March 27, 2025 10:58
Shop as Client - Change fields position/priority on the WooCommerce Checkout
<?php
/**
* Plugin Name: Shop as Client for WooCommerce - Fix field priority
* Description: Fix the field priority if messed up by another plugin
* Version: 1.0
* Author: PT Woo Plugins (by Webdados)
* Author URI: https://ptwooplugins.com/
* Requires at least: 5.8
* Tested up to: 6.8
* Requires PHP: 7.4
@webdados
webdados / kk_adjust_price.php
Last active March 19, 2025 14:15
Example usage of Feed KuantoKusta para WooCommerce add-on PRO adjust price filters
<?php
// Example 1
// Do not adjust any KuantoKusta price for products belonging to categories 90 and 333
add_filter( 'kuantokusta_adjust_product_regular_price', 'my_kk_adjust_price_filter', 10, 2 );
add_filter( 'kuantokusta_adjust_product_current_price', 'my_kk_adjust_price_filter', 10, 2 );
add_filter( 'kuantokusta_adjust_variation_regular_price', 'my_kk_adjust_price_filter', 10, 2 );
add_filter( 'kuantokusta_adjust_variation_current_price', 'my_kk_adjust_price_filter', 10, 2 );
function my_kk_adjust_price_filter( $price, $product ) {
$categories_not_to_adjust_price = array(
90,
@webdados
webdados / gateway_ifthen_blocks_payment_method_data.php
Created January 4, 2025 11:04
Change the ifthenpay gateway icon on the WooCommerce blocks checkout
<?php
// For ifthenpay Gateway use gateway_ifthen_blocks_payment_method_data
add_filter(
'gateway_ifthen_blocks_payment_method_data',
function ( $payment_method_data ) {
$payment_method_data['icon'] = '/whatever/path/apple-google-pix.svg';
$payment_method_data['icon_width'] = 78;
$payment_method_data['icon_height'] = 24;
return $payment_method_data;
}
<?php
// You need this plugin: https://ptwooplugins.com/product/dpd-portugal-for-woocommerce/
// Change order status after issuing label
add_action( 'woo_dpd_portugal_label_issued', function( $order_id ) {
$order = wc_get_order( $order_id );
$order->update_status( 'completed', 'Order automatically set to Completed after issuing DPD label' );
} );
@webdados
webdados / remove_plugin_from_wporg_updates.php
Last active October 11, 2024 12:08
Remove 3rd party plugin from WordPress.org updates checks
<?php
/**
* Remove this plugin from the wp.org update requests by shortcircuiting the HTTP request
* This function should be placed on the plugin main file and namespaced accordingly
* Unfortunately, this will only work if the plugin is active
*
* @param array $parsed_args An array of HTTP request arguments.
* @param string $url The request URL.
*/
function namespace_this_remove_plugin_from_wporg_updates( $parsed_args, $url ) {
@webdados
webdados / woocommerce_email_styles_dpd_pickup.php
Created October 4, 2024 16:45
Style DPD Pickup for WooCommerce point information on emails
<?php
/**
* https://ptwooplugins.com/product/dpd-seur-geopost-pickup-and-lockers-network-for-woocommerce/
*
* #woo_dpd_pickup_point_information is the outter DIV for all the point information
* .woo_dpd_pickup_point_information_schedule is the SMALL tag for the schedule information
* .woo_dpd_pickup_point_information_icon_schedule is the SPAN tag for the schedule icon
*/
@webdados
webdados / woocommerce_sale_flash.php
Created August 28, 2024 09:34
Show percentage sales badge for products that are on sale but not with a "Taxonomy/Term and Role based Discounts for WooCommerce" rule applied
<?php
/**
* Taxonomy/Term and Role based Discounts for WooCommerce lets you configure discounts/pricing rules for products based on any WooCommerce product taxonomy terms (built-in or custom), in a very simple way.
* Free version: https://wordpress.org/plugins/taxonomy-discounts-woocommerce/
* PRO Add-on: https://ptwooplugins.com/product/taxonomy-term-and-role-based-discounts-for-woocommerce-pro-add-on/
**/
add_filter( 'woocommerce_sale_flash', function( $html, $post, $product ) {
// Taxonomy/Term and Role based Discounts for WooCommerce (Free) is active?
if ( function_exists( 'WC_Taxonomy_Discounts_Webdados' ) ) {
@webdados
webdados / invoicexpress_woocommerce_vat_position_my_account.php
Created August 21, 2024 08:47
Change the VAT number position on the My Account and Thank You order details on the Invoicing with InvoiceXpress for WooCommerce plugin
<?php
/**
* https://ptwooplugins.com/product/invoicing-with-invoicexpress-for-woocommerce-pro/
* https://invoicewoo.com/
*/
// Change hook
add_filter( 'invoicexpress_woocommerce_vat_position_my_account', function( $hook ) {
return 'woocommerce_order_details_after_order_table';
} );
@webdados
webdados / kuantokusta_product_node_default_shipping.php
Created August 1, 2024 14:42
Kuanto Kusta for WooCommerce - Set free shipping for products above a certain price
<?php
add_filter( 'kuantokusta_product_node_default_shipping', 'kuantokusta_default_free_shipping', 10, 3 );
add_filter( 'kuantokusta_product_node_variation_shipping', 'kuantokusta_variation_free_shipping', 10, 3 );
function kuantokusta_default_free_shipping( $shipping_cost, $product, $product_type ) {
return kuantokusta_free_shipping( $shipping_cost, $product );
}
function kuantokusta_variation_free_shipping( $shipping_cost, $product, $variation ) {
return kuantokusta_free_shipping( $shipping_cost, $variation );
}
function kuantokusta_free_shipping( $shipping_cost, $product_or_variation ) {