Skip to content

Instantly share code, notes, and snippets.

@sc0ttkclark
Last active January 25, 2021 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sc0ttkclark/e130fd67b950a40e96638a4fffd1aaef to your computer and use it in GitHub Desktop.
Save sc0ttkclark/e130fd67b950a40e96638a4fffd1aaef to your computer and use it in GitHub Desktop.
Filter empty/invalid orders when refunded orders returns false values.
<?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