Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Tell SearchWP to index WooCommerce Orders https://searchwp.com/docs/kb/searching-woocommerce-orders/
<?php
/**
* Tell SearchWP that it can index WooCommerce Orders.
*/
add_filter( 'searchwp_indexed_post_types', function( $post_types ) {
if ( ! is_array( $post_types ) ) {
$post_types = (array) $post_types;
}
if ( ! in_array( 'shop_order', $post_types ) ) {
$post_types[] = 'shop_order';
}
return $post_types;
} );
/**
* Tell SearchWP to index all WooCommerce Order post statuses.
*/
add_filter( 'searchwp_post_statuses', function( $post_statuses, $engine ) {
if ( ! is_array( $post_statuses ) ) {
$post_statuses = (array) $post_statuses;
}
return array_unique( array_merge( $post_statuses, array(
'wc-pending',
'wc-processing',
'wc-on-hold',
'wc-completed',
'wc-cancelled',
'wc-refunded',
'wc-failed',
) ) );
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.