Search for multiple order ID in Woocommerce

I would like to search for multiple orders using the search by order ID section of the order page in woocommerce. By default, woocommerce only allows you to search for one order at a time (I tried to use the comma but it gave me an error) add_action('restrict_manage_posts', 'custom_filter_orders_by_ids'); function custom_filter_orders_by_ids() { global $typenow; if ($typenow == 'shop_order') { ?> <input type="text" name="custom_order_ids" placeholder="Enter order IDs separated by commas" value="<?php echo isset($_GET['custom_order_ids']) ? esc_attr($_GET['custom_order_ids']) : ''; ?>" /> <?php } } add_filter('parse_query', 'filter_orders_by_custom_ids'); function filter_orders_by_custom_ids($query) { global $pagenow; if ($pagenow == 'edit.php' && isset($_GET['post_type']) && $_GET['post_type'] == 'shop_order' && isset($_GET['custom_order_ids']) && !empty($_GET['custom_order_ids'])) { $order_ids = array_map('intval', explode(',', $_GET['custom_order_ids'])); $query->query_vars['post__in'] = $order_ids; } }

Comment (0)

You’ll be in good company