Skip to content

Feature: Add WooCommerce HPOS compatibility for orders - #4038

Open
felipeelia wants to merge 60 commits into
developfrom
feature/wc-hpos-issue-3476
Open

Feature: Add WooCommerce HPOS compatibility for orders#4038
felipeelia wants to merge 60 commits into
developfrom
feature/wc-hpos-issue-3476

Conversation

@felipeelia

@felipeelia felipeelia commented Dec 10, 2024

Copy link
Copy Markdown
Member

Description of the Change

Adds ElasticPress support for WooCommerce High-performance order storage (HPOS) on the admin Orders list.
When HPOS is enabled and WooCommerce is 9.8.0 or greater, ElasticPress now:

  • Indexes HPOS orders into the post indexable
  • Intercepts HPOS order list queries via woocommerce_hpos_pre_query
  • Translates HPOS query args into Elasticsearch-compatible queries (OrdersHPOS / OrdersHPOSQuery)
  • Continues to support Orders Autosuggest on ElasticPress.io when HPOS is compatible
    Compatibility details:
  • HPOS integration requires WooCommerce 9.8.0+ (ep_woocommerce_hpos_min_version)
  • On WooCommerce below 9.8.0 with HPOS enabled, EP does not integrate with the orders list and shows an admin notice
  • Orders stored as posts remain supported on older WooCommerce versions
  • Autosuggest is only marked HPOS-incompatible when HPOS is actually enabled on an unsupported WooCommerce version

Closes #3476

How to test the Change

  1. On WooCommerce 9.8.0+, enable HPOS (wp wc hpos enable), enable WooCommerce + Protected Content, and sync.
  2. Visit WooCommerce → Orders (admin.php?page=wc-orders) and confirm list search/filters go through Elasticsearch.
  3. Create/update an order and confirm it is indexed/updated.
  4. With ElasticPress.io available, enable Orders Autosuggest and confirm suggestions appear on the HPOS orders screen.
  5. On WooCommerce below 9.8.0 with HPOS enabled, confirm:
    • EP does not integrate with the HPOS orders list
    • The HPOS incompatibility notice appears on the orders screen
    • Autosuggest shows the HPOS version help message
  6. Disable HPOS (orders as posts) on WooCommerce below 9.8.0 and confirm legacy order search/autosuggest still work.

Changelog Entry

Added - Compatibility with WooCommerce High-performance order storage (HPOS) for the admin Orders list on WooCommerce 9.8.0+.

Credits

Props @felipeelia @burhandodhy

Checklist:

@felipeelia felipeelia added this to the 5.2.0 milestone Dec 10, 2024
@felipeelia felipeelia modified the milestones: 5.2.0, 5.3.0 Apr 10, 2025
@felipeelia felipeelia modified the milestones: 5.3.0, 5.4.0 Sep 18, 2025
@burhandodhy
burhandodhy force-pushed the feature/wc-hpos-issue-3476 branch from ce29915 to 9d558a0 Compare February 12, 2026 08:12
@burhandodhy
burhandodhy force-pushed the feature/wc-hpos-issue-3476 branch from 2317e7e to da0040e Compare February 19, 2026 07:46
@burhandodhy burhandodhy changed the title [WIP] Initial exploration of compatibility with WC HPOS Feature: Add WooCommerce HPOS compatibility for orders Aug 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds WooCommerce HPOS order indexing and Elasticsearch-backed order queries for WooCommerce 9.8+.

Changes:

  • Adds HPOS indexing, query translation, notices, and settings.
  • Extends order autosuggest compatibility.
  • Adds PHP/E2E coverage and updates minimum test versions.

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
.github/workflows/playwright.yml Updates minimum WP/WooCommerce versions.
composer.lock Upgrades WooCommerce test dependency.
includes/classes/Feature/WooCommerce/Orders.php Integrates HPOS settings and lifecycle.
includes/classes/Feature/WooCommerce/OrdersAutosuggest.php Adds HPOS autosuggest compatibility.
includes/classes/Feature/WooCommerce/OrdersHPOS.php Implements HPOS indexing and interception.
includes/classes/Feature/WooCommerce/OrdersHPOSQuery.php Translates HPOS queries for Elasticsearch.
includes/classes/Feature/WooCommerce/Products.php Formats tax-adjusted prices.
includes/classes/Feature/WooCommerce/WooCommerce.php Adds the HPOS setting default.
tests/e2e/src/block-editor.ts Updates editor compatibility helpers.
tests/e2e/src/specs/general.spec.ts Updates WP 6.4 selector handling.
tests/e2e/src/specs/related-posts.spec.ts Updates WP 6.4 editor behavior.
tests/e2e/src/specs/woocommerce.spec.ts Adds HPOS order and autosuggest flows.
tests/e2e/src/utils.ts Updates WP 6.4 utility branches.
tests/php/bootstrap.php Installs HPOS database tables.
tests/php/features/WooCommerce/TestWooCommerce.php Verifies the new setting schema.
tests/php/features/WooCommerce/TestWooCommerceOrders.php Adds extensive HPOS query tests.
tests/php/features/WooCommerce/TestWooCommerceOrdersAutosuggest.php Tests HPOS autosuggest availability.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread includes/classes/Feature/WooCommerce/Orders.php Outdated
Comment thread includes/classes/Feature/WooCommerce/OrdersHPOS.php
Comment thread includes/classes/Feature/WooCommerce/OrdersHPOS.php Outdated
Comment thread includes/classes/Feature/WooCommerce/OrdersHPOS.php
Comment thread includes/classes/Feature/WooCommerce/OrdersHPOS.php
Comment thread includes/classes/Feature/WooCommerce/OrdersHPOS.php
Comment thread includes/classes/Feature/WooCommerce/OrdersHPOS.php Outdated
Comment thread includes/classes/Feature/WooCommerce/OrdersHPOSQuery.php
Comment thread includes/classes/Feature/WooCommerce/OrdersAutosuggest.php

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 19 changed files in this pull request and generated no new comments.

Suppressed comments (4)

includes/classes/Feature/WooCommerce/OrdersHPOSQuery.php:845

  • In build_customer_meta_clause(), the meta_query for _customer_user uses compare => '=' while value is an array of IDs. WP_Meta_Query expects IN/NOT IN when value is an array; using = here can lead to customer ID filtering not working (including for nested [ id, email ] cases where $ids still becomes an array).
				'key'     => '_customer_user',
				'value'   => $ids,
				'compare' => '=',
				'type'    => 'NUMERIC',
			];

includes/classes/Feature/WooCommerce/OrdersHPOSQuery.php:853

  • Similarly, the _billing_email customer clause uses compare => '=' with an array of emails. This should use IN to behave correctly when multiple emails are provided.
			$clauses[] = [
				'key'     => '_billing_email',
				'value'   => $emails,
				'compare' => '=',
			];

includes/classes/Feature/WooCommerce/Orders.php:361

  • Typo in the docblock: “ElasticPres” should be “ElasticPress”.
	 * Display a notice when HPOS order queries are not integrated with ElasticPres.

includes/classes/Feature/WooCommerce/Products.php:202

  • get_price_filter_tax_adjustment() is documented to return a float and is used to populate numeric Elasticsearch range bounds, but wc_format_decimal() returns a string. Casting back to float keeps the return type consistent and avoids subtle type/empty() edge cases.
		return wc_format_decimal( $price - \WC_Tax::get_tax_total( \WC_Tax::calc_inclusive_tax( $price, $tax_rates ) ) );

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compatibility with WooCommerce HPOS

3 participants