Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make backend orders search optional in settings #63

Closed
jfretin opened this issue Feb 1, 2018 · 5 comments
Closed

Make backend orders search optional in settings #63

jfretin opened this issue Feb 1, 2018 · 5 comments

Comments

@jfretin
Copy link
Contributor

jfretin commented Feb 1, 2018

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!

@rayrutjes
Copy link
Owner

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?

@jfretin
Copy link
Contributor Author

jfretin commented Feb 1, 2018

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 😉

@rayrutjes
Copy link
Owner

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?

@jfretin
Copy link
Contributor Author

jfretin commented Feb 1, 2018

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

@urlund
Copy link
Contributor

urlund commented Aug 8, 2018

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

rayrutjes pushed a commit that referenced this issue Aug 9, 2018
…ckend search

A simple and backwards compatible solution to fix #63 via (eg.) functions.php

function should_wc_osa_orders_filter_search( $value, WP_Query $query ) {
    return false;
}

add_filter( 'wc_osa_orders_search_should_filter_query', 'should_wc_osa_orders_filter_search', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants