We’re updating our website and would love to take advantage of HPOS with woocoomerce, however, it looks like this plugin is preventing us from moving over to the faster way. Will there be an update for that?
]]>Please update this fine plugin to work with HPOS.
Thank you ??
]]>Is WC Search Orders By Product 100% compatible with PHP 8.1 ?
]]>When this plugin is enabled, no subscriptions are visible in Woocommerce subscription overview. Filtering of any kind won’t work.
Works just fine when this plugin is disabled.
Just a head’s up…
]]>BUG with WooCommerce Trashed Orders
Create a woocommerce order and delete it so it is in the trash.
On the woocommerce orders page, you will see that there is 1 order in your Trash.
CLick on the trash link to view, and when this plugin is active, it returns NO ORDERS FOUND IN TRASH. Deactivate this plugin and click trash link again and you can now see the trashed order.
]]>The “basket” filter still does not work, how could it be solved?
]]>Hi,
When i active your plugin, i cant see the order that i have in trash https://prnt.sc/1rfjai6
Thanks for the help!
]]>Hi,
I use Woocommerce Subscription and WC Search Orders By Product. But it causes a crash with woocommerce subscriptions. If I do disable “WC Search Orders By Product” it works fine.
Here’s a screenshot of what happens in woocommerce subscriptions when your plugin is enabled:
https://ibb.co/TYjD4Y2
This is a really great enhancement – but (always a but) unfortunately when activated you cannot see orders that have been placed into ‘trash’, even though they still show up as a row count in the menu eg. trash(2).
Deactivating the plugin lets orders with [post_status=trash] show up again, I’ve also confirmed this glitch with another relatively clean WP install with all other plugins deactivated. Same result.
FYI orders look perfectly fine in the DB tables and since they work fine with the plugin deactivated I don’t think the data is the issue.
As every other [post_status] is fine NOR can I find any other glitches on the page I don’t think this is a coding error, rather I suspect the looping code that is being modified to link products with the orders(to allow filtering) simply isn’t finding records with [post_status=trash].
Because all other order status works fine this suggests woocommerce handles records with [post_status=trash] slightly differently – though that’s way beyond my expertise.
This also explains why the menu still shows up a ‘trash’ count – the code here probably isn’t modified at all.
Admittedly this isn’t something many users would even worry about too much. However in my case the client will have back-end access (highly restricted) and this will be confusing.
So I’ve had to hard-code out the Woocommerce ‘trash’ references but obviously I’d prefer *not* to do that to woocommerce files. I’ve emailed the developer and are waiting to hear back – I’m happy to hard code in any required changes ??
]]>Hi,
We have a long list of categories but only need to filter on 2 categories. How can we use your plugin to show only 2 categories in the drop-down?
Very many thanks,
Phil.
would like to search from order detail page.
]]>It is possible to sort orders by product variations?
]]>Here are several improvements when filtering by product category (use query instead of looping through all orders) and adding possibility to clear the product input.
Patch:
diff --git a/wp-content/plugins/wc-search-orders-by-product/classes/class-wc-search-orders-by-product-admin.php b/wp-content/plugins/wc-search-orders-by-product/classes/class-wc-search-orders-by-product-admin.php
index 63e05d2..4a3aaaf 100644
--- a/wp-content/plugins/wc-search-orders-by-product/classes/class-wc-search-orders-by-product-admin.php
+++ b/wp-content/plugins/wc-search-orders-by-product/classes/class-wc-search-orders-by-product-admin.php
@@ -68,7 +68,7 @@ class WC_Search_Orders_By_Product_Admin {
}
}
?>
- <select class="woo-orders-search-by-product" style="width:203px;" id="product_id" name="product_id" data-placeholder="<?php esc_attr_e( 'Search for a product…', $WC_Search_Orders_By_Product->text_domain ); ?>" data-action="search_woo_products">
+ <select class="woo-orders-search-by-product" style="width:203px;" id="product_id" name="product_id" data-placeholder="<?php esc_attr_e( 'Search for a product…', $WC_Search_Orders_By_Product->text_domain ); ?>" data-action="search_woo_products" data-allow_clear="true">
<option value="<?php echo esc_attr( $product_id ); ?>" selected="selected"><?php echo htmlspecialchars( $product_name ); ?><option>
</select>
<?php
@@ -303,30 +303,20 @@ class WC_Search_Orders_By_Product_Admin {
* @return array
*/
public function sobp_get_orders_by_product_category($product_category_slug) {
+ global $wpdb;
+
$filtered_order_ids = array();
$term = get_term_by( 'slug', $product_category_slug, 'product_cat');
if ( $term && ! is_wp_error( $term ) ) {
- $category_id = $term->term_id;
- $all_orders = wc_get_orders( array(
- 'limit' => -1,
- 'return' => 'ids',
- ) );
- if ( ! empty( $all_orders ) ) {
- foreach ( $all_orders as $order_id ) {
- $order = wc_get_order( $order_id );
- foreach ( $order->get_items() as $item_id => $item ) {
- $product = $item->get_product();
- if(is_object($product)) {
- $sobp_product_categories = $product->get_category_ids();
- if(!empty($sobp_product_categories)){
- if (in_array($category_id,$sobp_product_categories)) {
- $filtered_order_ids[] = $order_id;
- }
- }
- }
- }
- }
- }
+ $category_product_ids = $this->get_products_in_category( $product_category_slug );
+
+ $filtered_order_ids = $wpdb->get_col( $wpdb->prepare("
+ SELECT order_id
+ FROM {$wpdb->prefix}woocommerce_order_items
+ WHERE order_item_id IN ( SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE meta_key = '_product_id' AND meta_value IN (" . implode(', ', array_fill(0, count($category_product_ids), '%s')) . ") )
+ AND order_item_type = 'line_item'
+ ", $category_product_ids));
+
if(!empty($filtered_order_ids)) {
return array_unique($filtered_order_ids);
}
]]>