I’m in the process of converting an open source plugin to be HPOS-compatible. One of its features is additional filters on the orders list in admin (inline with the order statuses), eg:
I can’t seem to actually execute the modification of the query. Previously, I was hooking into pre_get_posts
which obviously is no longer relevant when WP_Post is no longer being used.
Then the same for a filter field, for which I was hooking into found the equivalent hook: restrict_manage_posts
.woocommerce_order_list_table_restrict_manage_orders
Anyone have an idea which hook to use?
2
Answers
On High-Performance Order Storage documentation, there is a link to High Performance Order Storage Upgrade Recipe Book where you will find the path(s) to related core files you are looking for.
In this documentation, you have:
that points to
woocommerce/src/Internal/DataStores/Orders
, whereOrdersTableQuery.php
file is the right location to look at.Inside the method
maybe_override_query()
you have at line 233:Inside the method
build_query()
you have at line 877:And so on…
As
WC_Order_Query
is used to query orders for HPOS, the following filters should still work:woocommerce_order_query_args
filter hook,woocommerce_order_query
filter hook,woocommerce_order_data_store_cpt_get_orders_query
filter hook.For
restrict_manage_post
hook replacement, you will have to search…I originally commented with a question, but deleted it, because I was understanding the strike-through incorrectly. I though you wrote that
woocommerce_order_list_table_restrict_manage_orders
is the replacement hook forpre_get_posts
.For others with similar low reading comprehension, the updated hooks for the admin order page are:
pre_get_posts
woocommerce_order_query_args
restrict_manage_posts
woocommerce_order_list_table_restrict_manage_orders
manage_edit-shop_order_columns
manage_woocommerce_page_wc-orders_columns
manage_shop_order_posts_custom_column
manage_woocommerce_page_wc-orders_custom_column
bulk_actions-edit-shop_order
bulk_actions-woocommerce_page_wc-orders
handle_bulk_actions-edit-shop_order
handle_bulk_actions-woocommerce_page_wc-orders
I’v also included some others that I had a hard time locating, mostly because
get_current_screen()->id
has changed for the admin order table.