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

Adds support for searching shop_subscriptions #2867 #3029

Merged
merged 4 commits into from
Nov 9, 2022
Merged

Adds support for searching shop_subscriptions #2867 #3029

merged 4 commits into from
Nov 9, 2022

Conversation

ecaron
Copy link
Contributor

@ecaron ecaron commented Sep 27, 2022

Description of the Change

This change expands the admin search functionality to work on shop_subscriptions just like it does on shop_orders today, expanding on the WooCommerce subscription-core functionality.

The behavior is just like shop_order, where it detects if the searched post_type is shop_subscription, and then it hijacks the behavior to route the search through Elasticsearch rather than WordPress' database.

Closes #2867

How to test the Change

  1. Install any plugin that leverages WooCommerce subscription-core
  2. Add a subscription
  3. Within the search interface, do a search with & without ElasticPress enabled - the search results will be the same (albeit ElasticPress' results will return much faster)

Changelog Entry

Changed - Admin search has been expanded to work on shop_subscription in addition to existing shop_order

Credits

Props @ecaron

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@ecaron
Copy link
Contributor Author

ecaron commented Oct 6, 2022

@felipeelia Any insight on what would be neeed to get this reviewed/merged?

@ecaron
Copy link
Contributor Author

ecaron commented Oct 17, 2022

@felipeelia Could you elaborate on what "needs discussion" means, so I can do the legwork to provide context? Or is it just an internal flag for the 10Up core team?

@felipeelia
Copy link
Member

Hey @ecaron, it is just a flag we use to bring it to our internal syncs. I'll get back to you here once we have anything new to share. Thanks for reaching out!

@felipeelia
Copy link
Member

Hey @ecaron, we've talked internally and as this is not strictly related to WooCommerce's core, the best place for it is actually as a subfeature in ElasticPress Labs (there we maintain compatibility with Co-Authors Plus, for example.)

To have that added to EP Labs, the code will be a bit bigger but if you want to give that a try, it would be great! Otherwise, we will try to address it as soon as possible. Thanks!

@ecaron
Copy link
Contributor Author

ecaron commented Oct 21, 2022

I understand. I'll create a PR for this as a subfeature to ElasticPress Labs. I started with this PR, but my goal is to have this move to a PR there by EOD.

I'll close this once that PR is opened.

@ecaron
Copy link
Contributor Author

ecaron commented Oct 21, 2022

@felipeelia, to help me understand the direction that you're looking to go and likely to approve, are you suggesting:

Option 1 - Isolating everything to ElasticPressLabs

  1. Replace the ElasticPress ep_wp_query_search_cached_posts action for disallow_duplicated_query
  2. Replace the ElasticPress pre_get_posts action for translate_args
    This would involve a massive amount of copy/paste, and likely to cause EPL to fall out of sync with future EP updates
  3. Replace the ElasticPress ep_sync_insert_permissions_bypass filter for bypass_order_permissions_check
  4. Replace the ElasticPress parse_query action for maybe_hook_woocommerce_search_fields and search_order
  5. Replace the ElasticPress ep_post_sync_args_post_prepare_meta filter for add_order_items_search
  6. Replace the ElasticPress ep_pc_skip_post_content_cleanup filter for keep_order_fields

Option 2 - Tweaks to ElasticPress to make hooking from EPL easier

  1. Adjust the altered if statements in this PR to rely on do_actions so external plugins can alter the logic
  2. Put the add_actions in the EPL feature to properly sideload support for shop_subscription

Option 99 - If the above aren't pleasant ideas for your vision of EPL's future

Since this PR only depends on the MIT-licensed Automattic woocommerce-subscription-core, it could be merged in as-is. That repo shows there are other paid plugins that depend on this core, beyond the 2 paid Automattic plugins, so this would inherently bring support for those plugins into ElasticPress core.

@felipeelia
Copy link
Member

Hey @ecaron, let's go with option #2, adding in the main plugin the actions and filters needed and then using them in EP Labs. Thanks!

@ecaron
Copy link
Contributor Author

ecaron commented Nov 6, 2022

Hey @ecaron, let's go with option #2, adding in the main plugin the actions and filters needed and then using them in EP Labs. Thanks!

This PR has been updated to include the hooks and filters mentioned in the aforementioned option 2. PR has been submitted at 10up/ElasticPressLabs#44 to leverage them.

@felipeelia felipeelia added this to the 4.4.0 milestone Nov 8, 2022
Copy link
Member

@felipeelia felipeelia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the code @ecaron. I've listed some changes we will need before merging this one but nothing major.

includes/classes/Feature/WooCommerce/WooCommerce.php Outdated Show resolved Hide resolved
includes/classes/Feature/WooCommerce/WooCommerce.php Outdated Show resolved Hide resolved
@ecaron ecaron requested a review from felipeelia November 9, 2022 15:56
@ecaron
Copy link
Contributor Author

ecaron commented Nov 9, 2022

@felipeelia The "E2E Test / Cypress - Local" failure seems unrelated to this PR (failing in #3129 and #3068). Do you see this being included in the 4.4.0 work covered under #3129, or should I update the PR to have it target 4.5.0?

@felipeelia
Copy link
Member

Hey @ecaron, I'm also keeping an eye on those tests :) . And this will be part of 4.4.0, no need to change anything (I'm just rerunning the tests to see if they unstuck now.) Thanks!

@felipeelia felipeelia merged commit 29793b7 into 10up:develop Nov 9, 2022
felipeelia added a commit that referenced this pull request Nov 9, 2022
@amanfredini76
Copy link

amanfredini76 commented Jul 11, 2024

@felipeelia PROBLEM
10up/ElasticPressLabs#108
can you reply please? it's urgent

@felipeelia
Copy link
Member

@amanfredini76 there is no point in commenting on a Pull Request closed in 2022, let's please keep your problem isolated in that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expand WooCommerce admin search to include WooCommerce Subscriptions
3 participants