Last active
January 25, 2021 17:07
-
-
Save sc0ttkclark/e130fd67b950a40e96638a4fffd1aaef to your computer and use it in GitHub Desktop.
Filter empty/invalid orders when refunded orders returns false values.
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 | |
// Filter the orders returned by WooCommerce so that any missing ones are removed from the list. | |
add_filter( 'woocommerce_order_query', static function( $posts ) { | |
// For some reason, $posts may not be an array. Some other plugin(s) may be using the filter incorrectly. | |
if ( is_array( $posts ) ) { | |
$posts = array_filter( $posts ); | |
} | |
return $posts; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment