rayrutjes / wc-order-search-admin

💵 Search for WooCommerce orders in the admin at the speed of thought with Algolia.

Home Page:https://wordpress.org/plugins/wc-order-search-admin/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make backend orders search optional in settings

jfretin opened this issue · comments

It would be nice if the orders search in backend can be disabled, via an option in the plugin settings for example.

I have a use case where some orders can be deleted from the index (for example they are too old), but the order still exists in woo DB! And I still want to be able to search it the 'old way' (wp_query).

Or maybe fallback to wp_query (or now wc_get_orders) when nb_hits is 0 from algolia?

What do you think?

By the way, great plugin!

Hi there @jfretin .

I think your use case totally makes sense.

However I'd like to keep the plugin as simple and plug & play as possible.

If you want to disable backend search, you can remove the hook registered here: https://github.com/rayrutjes/wc-order-search-admin/blob/master/includes/admin/class-orders-list-page.php#L35

Would that work in your case?

yes, of course by commenting the line it works as expected.

The problem is that I would have to do it everytime you're updating your plugin.
And your instance of \WC_Order_Search_Admin\Admin\Orders_List_Page is not global and have no singleton method, I can't remove the action with remove_action for example (I think it would be possible this way).

For the time being, I'll comment the line 😉

You are right, there is no way to cleanly remove the action as is :/

Maybe the easiest is to transform this class to a singleton so that you can actually remove the action.

Is this something you'd be willing to open a PR for?

I'll try to do it when I find some time 😬

Created #71 because I needed search for custom fields, like PDF invoice number - hopefully it will be merged ;)