This file contains hidden or 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 hidden or 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 hidden or 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; |
This file contains hidden or 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 | |
//Inspiration: https://gist.github.com/florianbrinkmann/a879099f3d28c5e1d64f2aeea042becf | |
add_action( 'do_faviconico', function() { | |
//Check for icon with no default value | |
if ( $icon = get_site_icon_url( 32 ) ) { | |
//Show the icon | |
wp_redirect( $icon ); | |
} else { | |
//Show nothing | |
header( 'Content-Type: image/vnd.microsoft.icon' ); |
This file contains hidden or 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/ | |
// Step 2 (ok) - Monitor the result (success) and do whatver you want with it - Needs to be set before running it | |
add_action( 'woo_dpd_portugal_label_issued', function( $order_id ) { | |
$order = wc_get_order( $order_id ); | |
echo 'Label issued for order '.$order_id.' on '.$order->get_meta( '_woo_dpd_portugal_label_issued' ).'<br/>'; | |
echo 'Tracking number(s): '.implode( ' / ', $order->get_meta( '_woo_dpd_portugal_tracking_number' ) ).'<br/>'; | |
echo 'Label PDF URL: '.$order->get_meta( '_woo_dpd_portugal_pdf_url' ).'<br/>'; |
This file contains hidden or 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 | |
//Uncomment next line to activate for Chronopost | |
//add_filter( 'cppw_available_points', 'remove_acores_madeira_pickup_points', 10, 2 ); | |
//Uncomment next line to activate for Chronopost | |
//add_filter( 'pvkw_available_points', 'remove_acores_madeira_pickup_points', 10, 2 ); | |
//The filter function | |
function remove_acores_madeira_pickup_points( $points, $postcode ) { | |
foreach ( $points as $key => $point ) { |
This file contains hidden or 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 | |
/* | |
- Save this PHP file to the root of your WordPress website | |
- Log in as Administrator | |
- Change the post ID on line 13 | |
- Call the PHP file it directly on your borwser | |
*/ | |
require('./wp-load.php'); |
This file contains hidden or 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 | |
remove_action( 'woocommerce_email_customer_details', array( WC_Emails::instance() , 'email_addresses' ), 20 ); |
This file contains hidden or 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( 'user_has_cap', 'wc_customer_has_capability_override_pay_for_order', 15, 3 ); | |
function wc_customer_has_capability_override_pay_for_order( $allcaps, $caps, $args ) { | |
if ( isset( $caps[0] ) ) { | |
switch ( $caps[0] ) { | |
case 'pay_for_order': | |
$allcaps['pay_for_order'] = true; | |
break; | |
} | |
} |
This file contains hidden or 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 you (child-)theme functions.php file */ | |
add_filter( 'shop_as_client_pro_search_order_statuses', 'my_shop_as_client_pro_search_order_statuses' ); | |
function my_shop_as_client_pro_search_order_statuses( $statuses ) { | |
//Only for Processing and Completed orders | |
$statuses = array( 'processing', 'completed' ); | |
//Return | |
return $statuses; |