Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created October 10, 2019 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jchristopher/029ed85802f81b3153c0c2b99b3553ea to your computer and use it in GitHub Desktop.
Save jchristopher/029ed85802f81b3153c0c2b99b3553ea to your computer and use it in GitHub Desktop.
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