Skip to content

Instantly share code, notes, and snippets.

View webdados's full-sized avatar

Marco Almeida webdados

View GitHub Profile
@webdados
webdados / cppw_map_dimensions.php
Created November 23, 2017 14:59
Override "Portugal Chronopost Pickup network for WooCommerce" map dimensions
<?php
add_filter( 'cppw_map_width', function( $width ) {
return 200;
} );
add_filter( 'cppw_map_height', function( $height ) {
return 100;
} );
@webdados
webdados / multibanco_ifthen_set_on_hold.php
Last active December 15, 2017 12:28
Multibanco IfThenPay - Keep order pending instead of on-hold
<?php
// Multibanco IfThen - Keep order pending instead of on-hold - Be advised that no "new order" email will be sent to the client
add_filter( 'multibanco_ifthen_set_on_hold', '__return_false' );
@webdados
webdados / pending_cancelled_send_an_email_notification.php
Last active December 18, 2017 10:50
Send cancelled pending orders email notifications
<?php
/* WooCommerce emails for cancelled pending orders */
add_action('woocommerce_order_status_pending_to_cancelled', 'pending_cancelled_send_an_email_notification', 10, 2 );
function pending_cancelled_send_an_email_notification( $order_id, $order ) {
if ( version_compare( WC_VERSION, '3.0.8', '>=' ) ) {
// Getting all WC_emails objects
$email_notifications = WC()->mailer()->get_emails();
// Sending the email
$email_notifications['WC_Email_Cancelled_Order']->trigger( $order_id );
@webdados
webdados / cancelled_order_add_customer_email.php
Last active December 16, 2017 03:33
WooCommerce Cancelled orders sent to client also
<?php
add_filter( 'woocommerce_email_recipient_cancelled_order', 'cancelled_order_add_customer_email', 10, 2 );
function cancelled_order_add_customer_email( $recipient, $order ) {
if ( $order ) {
return $recipient . ',' . ( version_compare( WC_VERSION, '3.0', '>=' ) ? $order->get_billing_email() : $order->billing_email );
} else {
return $recipient;
}
}
@webdados
webdados / multibanco_ifthen_cancel_unpaid_orders.php
Created December 15, 2017 18:03
Auto cancellation of WooCommerce Multibanco orders if "Manage stock" and "Hold stock (minutes)" are configured
<?php
// Multibanco IfThen - Cancel orders if "Manage stock" and "Hold stock (minutes)" are configured - Be advised that the Multibanco reference will still be active and can be paid
add_filter( 'multibanco_ifthen_cancel_unpaid_orders', '__return_true' );
@webdados
webdados / woocommerce_helper_suppress_admin_notices.php
Created January 30, 2018 21:51
Hide WooCommerce 3.3 (and above) helper notices, such as extensions updates and connection to WooCommerce.com request
<?php add_filter( 'woocommerce_helper_suppress_admin_notices', '__return_true' ); ?>
@webdados
webdados / woocommerce_hide_default_category.php
Created February 8, 2018 10:38
Hide WooCommerce (3.3 and above) default category
<?php
/* Hide WooCommerce default category on the frontend */
add_filter( 'woocommerce_product_subcategories_args', 'woocommerce_hide_default_category' );
function woocommerce_hide_default_category( $args ) {
$args['exclude'] = get_option( 'default_product_cat' );
return $args;
}
@webdados
webdados / resizeandcanvasto1200.jsx
Last active April 26, 2020 17:26
Automatic resize a folder of images into the same square size on Adobe Photoshop. Just right click the file and open it with Photoshop.
//Marco Almeida - Webdados
#target photoshop
app.bringToFront();
app.preferences.rulerUnits = Units.PIXELS;
gFilesToSkip = Array( "db", "xmp", "thm", "txt", "doc", "md0", "tb0", "adobebridgedb", "adobebridgedbt", "bc", "bct" );
@webdados
webdados / remove_wc_add_to_cart_message_html.php
Created March 1, 2018 17:22
Remove WooCommerce "Added to cart" message
<?php
/* Removes the "added to cart" message and "continue shopping" link after a product was added to the cart and the user was redirected to the cart page */
add_filter( 'wc_add_to_cart_message_html', 'remove_wc_add_to_cart_message_html' );
function remove_wc_add_to_cart_message_html( $message ) {
$message = '';
return $message;
}
?>
@webdados
webdados / pvkw_map_dimensions.php
Created March 5, 2018 10:16
Override "Portugal VASP Expresso Kios network for WooCommerce" map dimensions
<?php
add_filter( 'pvkw_map_width', function( $width ) {
return 200;
} );
add_filter( 'pvkw_map_height', function( $height ) {
return 100;
} );