I used a plugin “WooCommerce Filter Orders by Product” and modified their search by ID, added a get_post_meta(), and now have the ability to filter products by ID.
Plugin: https://en-ca.wordpress.org/plugins/woocommerce-filter-orders-by-product/
Modified code:
// Display dropdown
function foa_product_filter_in_order(){
global $typenow, $wpdb;
if ( 'shop_order' != $typenow ) {
return;
}
$sql="SELECT ID,post_title FROM $wpdb->posts WHERE post_type="product" AND post_status="publish"";
$all_posts = $wpdb->get_results($sql, ARRAY_A);
$values = array();
foreach ($all_posts as $all_post) {
$values[$all_post['ID']] = get_post_meta($all_post['ID'], '_sku', true);
}
?>
<select name="foa_order_product_filter">
<option value=""><?php _e('All products', 'foa'); ?></option>
<?php
$current_v = isset($_GET['foa_order_product_filter'])? $_GET['foa_order_product_filter']:'';
foreach ($values as $label) {
printf
(
'<option value="%s"%s>%s</option>',
$value,
$value == $current_v? ' selected="selected"':'',
$label
);
}
?>
</select>
<?php
}