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

Orders autosuggest foundations #3175

Merged
merged 9 commits into from
Feb 2, 2023
Merged

Conversation

JakePT
Copy link
Contributor

@JakePT JakePT commented Dec 2, 2022

Description of the Change

The PR implements the foundations for the orders autosuggest for WooCommerce feature. It includes:

  • A class for the Orders sub-feature, this incudes:
    • Creating and saving the search template for the order search API on ElasticPress.io.
    • Retrieving and setting a temporary token for authenticated front-end requests to ElasticPress.io.
    • Loading front-end assets.
  • The UI.

The class is not instantiated in the WooCommerce feature, so it can not be currently activated.

Screenshot 2023-02-01 at 12 39 22 am

Remaining to be implemented, as per #3277, are:

  • A new field and ngram that includes the order number, first name, last name, and email address to support partial word matches and highlighting.
  • A UI toggle for enabling Orders Autosuggest.
  • Logic to index Orders when feature is active, even if Protected Content is disabled.
  • Logic to require index when the feature is activated.
  • Tests.

How to test the Change

  1. Connect to an EP.io environment that supports the order search API.
  2. Activate the WooCommerce and Protected Content features.
  3. Add ( new Orders() )->setup(); to the setup() method of the WooCommerce feature class.
  4. Perform an index.
  5. Visit WooCommerce > Orders and start searching for orders. Suggestions should be offered in a listbox below the search form.

Changelog Entry

  • Added: Autosuggest for WooCommerce Orders.

Credits

@JakePT

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.

@JakePT JakePT self-assigned this Dec 2, 2022
@felipeelia felipeelia added this to the 4.5.0 milestone Dec 8, 2022
@JakePT JakePT added enhancement front end Issues mostly related to the Front End like JavaScript/React and CSS. module:woocommerce Issues related to the WooCommerce functionality labels Jan 12, 2023
@JakePT JakePT changed the title WIP: Orders autosuggest Orders autosuggest foundations Jan 27, 2023
@JakePT JakePT marked this pull request as ready for review January 27, 2023 14:54
@JakePT JakePT assigned felipeelia and unassigned JakePT Jan 27, 2023
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.

@JakePT I left some comments (mostly just thoughts and things we will need to keep track of). Do you mind reaching out to me on slack to share an endpoint I can use to test it? Thanks!

includes/classes/Feature/WooCommerce/Orders.php Outdated Show resolved Hide resolved
includes/classes/Feature/WooCommerce/Orders.php Outdated Show resolved Hide resolved
includes/classes/Feature/WooCommerce/Orders.php Outdated Show resolved Hide resolved

$token = base64_encode( "$response->username:$response->clear_password" ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode

update_user_meta( $user_id, 'ep_temporary_token', $token );
Copy link
Member

Choose a reason for hiding this comment

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

We need to delete these during the plugin uninstall. Also, this will eventually expire, right? I didn't find where we are getting a new one if that is the case, sorry :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@felipeelia Yeah I'll check with Dustin how we want to do that. At the moment it's treated as if the tokens are permanent.

@felipeelia felipeelia assigned JakePT and unassigned felipeelia Jan 31, 2023
@JakePT JakePT assigned felipeelia and unassigned JakePT Feb 1, 2023
@felipeelia felipeelia merged commit dfd6c76 into develop Feb 2, 2023
@felipeelia felipeelia deleted the feature/orders-autosuggest branch February 2, 2023 21:33
@JakePT JakePT mentioned this pull request Feb 27, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement front end Issues mostly related to the Front End like JavaScript/React and CSS. module:woocommerce Issues related to the WooCommerce functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants