woocommerce
woocommerce copied to clipboard
Trigger doint_it_wrong for CPT order queries with HPOS query args
Submission Review Guidelines:
- I have followed the WooCommerce Contributing Guidelines and the WordPress Coding Standards.
- I have checked to ensure there aren't other open Pull Requests for the same update/change.
- I have reviewed my code for security best practices.
- Following the above guidelines will result in quick merges and clear and detailed feedback when appropriate.
Changes proposed in this Pull Request:
Closes #46076.
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
Changelog entry
- [ ] Automatically create a changelog entry from the details below.
Significance
- [ ] Patch
- [ ] Minor
- [ ] Major
Type
- [ ] Fix - Fixes an existing bug
- [ ] Add - Adds functionality
- [ ] Update - Update existing functionality
- [ ] Dev - Development related task
- [ ] Tweak - A minor adjustment to the codebase
- [ ] Performance - Address performance issues
- [ ] Enhancement - Improvement to existing functionality
Message
Comment
Test using WordPress Playground
The changes in this pull request can be previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.
Test this pull request with WordPress Playground.
Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit.
Hi @naman03malhotra,
Apart from reviewing the code changes, please make sure to review the testing instructions as well.
You can follow this guide to find out what good testing instructions should look like: https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions
Hi @naman03malhotra,
Apart from reviewing the code changes, please make sure to review the testing instructions as well.
You can follow this guide to find out what good testing instructions should look like: https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions
@naman03malhotra: You're right. WP-CLI is a different environment than the web one, so the error reporting needs to be explicitly set or it'd just use the defaults (which I guess on your machine are not to display certain warnings). You should still have been able to confirm those messages in your error log file, but an alternative way to enable error reporting is to execute the following (in the wp shell) before anything else:
error_reporting( E_ALL );
ini_set( 'display_errors', true );
[...]
Please let me know if the above works and I'll update the testing instructions accordingly.
Hey @naman03malhotra! I've implemented Corey's suggestion which should help with 3rd party code in case it (somehow) adds support for the HPOS-only query vars to CPT. I've reworked the testing instructions to take this into account. Please let me know what you think!
@naman03malhotra: I can't reproduce and can't think of reasons for such error, but I've updated the snippet with a less 'clever' version to see if that helps. Please let me know if it works for you.
For now what is the correct way to get the orders based on the custom meta value?
My args passed to wc_get_orders($args) are:
Array
(
[paginate] => 1
[limit] => 25
[paged] => 1
[meta_query] => Array
(
[relation] => AND
[0] => Array
(
[key] => _omnivalt_method
[value] => Array
(
[0] => omnivalt
[1] => omnivalt_pt
[2] => omnivalt_c
[3] => omnivalt_cp
[4] => omnivalt_pc
[5] => omnivalt_pn
[6] => omnivalt_ps
)
[compare] => IN
)
)
)
Since version WC 9.2.0 I just get the error "Order query argument (meta_query) is not supported on the current order datastore" and see empty page.
@markakk the meta_query arg already didn't work with the "legacy" WordPress posts storage option for orders (now it just gives you a notice about it). If you go to WooCommerce > Settings > Advanced > Features and enable "High-performance order storage", you should be able to use meta_query.