This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'sanitize_file_name', 'my_sanitize_file_name' ); | |
function my_sanitize_file_name( $filename ) { | |
$original_chars = array( | |
'/А/','/Б/','/В/','/Г/', // cyrillic alphabet | |
'/Д/','/Е/','/Ж/','/З/','/И/', | |
'/Й/','/К/','/Л/','/М/','/Н/', | |
'/О/','/П/','/Р/','/С/','/Т/', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Add this to your (child-)theme functions.php file | |
//Before woocommerce_email_after_order_table 1 and woocommerce_order_details_after_order_table 1, because on the woocommerce_order_barcodes_display_barcode filter we don't have access to the $order object | |
add_action( 'woocommerce_email_after_order_table', 'custom_prevent_barcode', -1, 1 ); | |
add_action( 'woocommerce_order_details_after_order_table', 'custom_prevent_barcode', -1, 1 ); | |
function custom_prevent_barcode( $order ) { | |
$allowed_statuses = array( | |
'processing', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wp_enqueue_scripts', 'my_remove_unnecessary_scripts_and_styles', PHP_INT_MAX ); | |
function my_remove_unnecessary_scripts_and_styles() { | |
//Remove Mapbox styles and scripts | |
global $post; | |
if ( ! ( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'wp_mapbox_gl_js' ) ) ) { | |
wp_dequeue_style( 'mapbox_gl_js_css' ); | |
wp_dequeue_style( 'mapbox_gl_js_geocoder_css' ); | |
wp_dequeue_style( 'mapbox_gl_js_directions_css' ); | |
wp_dequeue_style( 'wp-mapbox-gl-js' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Hire me at webdados.pt for more WooCommerce magic */ | |
//The function that determines if the shop is closed or not | |
function custom_shop_closed() { | |
//Week days closed - ISO-8601 numeric representation of the day of the week - 1 (for Monday) through 7 (for Sunday) | |
$week_days_closed = array( 5, 6 ); //Fridays and Saturdays | |
//Hours closed | |
$min_hour_close = '07:00'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//You need this plugin: https://www.webdados.pt/wordpress/plugins/dpd-portugal-para-woocommerce-wordpress/ | |
//Monitor the result (success) and do whatver you want with it - Needs to be set before running it | |
add_action( 'woo_dpd_portugal_requested_pickup', function( $pickup_request ) { | |
var_dump( $pickup_request ); //You should email it, or log it, or... whatever | |
} ); | |
//Monitor the result (error) and do whatver you want with it - Needs to be set before running it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'invoicexpress_woocommerce_automatic_invoice_possible_status', function( $statuses ) { | |
$statuses[] = 'wc-picking'; | |
$statuses[] = 'wc-another-one-bites-the-dust'; | |
return $statuses; | |
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_product_add_to_cart_text', 'my_woocommerce_product_add_to_cart_text', 10, 2 ); | |
add_filter( 'woocommerce_product_single_add_to_cart_text', 'my_woocommerce_product_add_to_cart_text', 10, 2 ); | |
function my_woocommerce_product_add_to_cart_text( $text, $product ) { | |
if ( $product->is_on_backorder() ) { | |
return 'Reservar'; | |
} | |
return $text; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'woocommerce_checkout_update_order_meta', function( $order_id, $data ) { | |
foreach ( WC()->cart->cart_contents as $item ) { | |
if ( $item['data']->is_on_backorder() ) { | |
$order = wc_get_order( $order_id ); | |
$order->update_meta_data( '_has_backorder_product', 1 ); | |
$order->save(); | |
break; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'invoicexpress_woocommerce_exccat_exclude_types', function( $exclude_types ) { | |
//Return an array of document types where all items should be invoiced and not excluded by category or tag | |
return array( | |
'transport_guide' | |
); | |
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//See here why this is needed: https://github.com/woocommerce/woocommerce/issues/26105 | |
function woocommerce_get_european_union_countries_after_wc4( $type = '' ) { | |
$countries = WC()->countries->get_european_union_countries(); | |
if ( 'eu_vat' === $type ) { | |
$countries[] = 'MC'; | |
$countries[] = 'IM'; | |
$countries[] = 'GB'; //Great Britain is still part of the EU VAT zone | |
} | |
return $countries; |