Repository navigation
Feature: Add WooCommerce HPOS compatibility for orders - #4038
Open
felipeelia wants to merge 83 commits into
Open
felipeelia wants to merge 83 commits into
felipeelia wants to merge 83 commits into
Conversation
1 task done
burhandodhy
force-pushed
the
feature/wc-hpos-issue-3476
branch
from
February 12, 2026 08:12
ce29915 to
9d558a0
Compare
burhandodhy
force-pushed
the
feature/wc-hpos-issue-3476
branch
from
February 19, 2026 07:46
2317e7e to
da0040e
Compare
There was a problem hiding this comment.
🟡 Changes recommended
HPOS-only full sync, metadata privacy, filter interoperability, pagination, and date-filter correctness have unresolved defects.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (3)
includes/classes/Feature/WooCommerce/OrdersHPOS.php:320
- Preserve an override supplied by an earlier
woocommerce_hpos_pre_querycallback. This filter's first argument is the accumulated pre-query result; returningnullhere discards another integration's valid result and causes either ElasticPress or WooCommerce SQL to run instead.
public function maybe_intercept_wc_orders_query( $order_data, OrdersTableQuery $query ) {
if ( ! $this->should_integrate_with_query( $query->get_query_args(), $query ) ) {
return null;
}
includes/classes/Feature/WooCommerce/OrdersHPOSQuery.php:124
- When callers provide both
offsetandpage, WooCommerce gives the explicit offset precedence, but ElasticPress's post query recalculatesfromfrompagedand overrides this offset. Resettingpagedwhen an offset is present preserves HPOS query semantics.
$offset = $this->hpos_query->get( 'offset' );
if ( ! empty( $offset ) ) {
$args['offset'] = absint( $offset );
includes/classes/Feature/WooCommerce/OrdersHPOSQuery.php:732
- WooCommerce's date query contract accepts Unix timestamps, but an integer
date_created/date_modifiedvalue is rejected here, sobuild_date_query()silently drops the filter. Permit numeric scalars and cast them before normalization.
protected function parse_date_shorthand( $value ): array {
if ( ! is_string( $value ) || empty( $value ) ) {
return [];
}
- Files reviewed: 20/21 changed files
- Comments generated: 5
- Review effort level: Balanced
Treat GMT date shorthand and exclusive date_query after values as GMT so Elasticsearch results match WooCommerce.
Treat an empty status as every post status, keep customer 0 as a guest filter, and count all orders still pending sync.
Read dates, parent, and notes from the edit context and store boolean meta the way WooCommerce does. Keep existing query results when Elasticsearch is skipped, and build the meta query in one pass.
Translate date_query and field_query in their own classes so Elasticsearch follows WooCommerce comparisons, and fall back when a query cannot be translated. Update the WooCommerce test dependency to 11.2.1.
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved compatibility, query-filtering, metadata preservation, and hook-cleanup defects can cause fatal errors or incorrect order retrieval.
6 open issues
HPOS hooks remain registered after switching to inactive sites · New HPOS integration calls unavailable WooCommerce 9.8.0 API · New Zero-valued HPOS order restrictions are dropped · New Refund custom metadata is not indexed · New Duplicate custom metadata values are lost during HPOS indexing · New Array-valued date constraints are silently discarded · New
5 resolved since last review
This bypasses the post indexable's metadata allowlist and sends every custom HPOS order meta value… Full sync still discovers documents through the post indexable'sWP_Query, whose indexable types… WooCommerce accepts Unix timestamps fordate_paidanddate_completed, but those arrive here as… After removing IDs that no longer exist in WooCommerce, the returnedfound_ordersand… Enabling this integration must trigger a sync. The upgrade routine intentionally disables it…
Review effort: Balanced
Give a set offset precedence over the page when a valid limit is set, and remove deleted refunds on woocommerce_delete_order_refund.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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.9.0 or greater, ElasticPress now:
woocommerce_hpos_pre_queryOrdersHPOS/OrdersHPOSQuery)Compatibility details:
ep_woocommerce_hpos_min_version)Closes #3476
How to test the Change
wp wc hpos enable), enable WooCommerce + Protected Content, and sync.admin.php?page=wc-orders) and confirm list search/filters go through Elasticsearch.Changelog Entry
Credits
Props @felipeelia @burhandodhy
Checklist: