Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Make WooCommerce Order Notes searchable by SearchWP
<?php
// Make WooCommerce Order Notes searchable by SearchWP.
// @link https://searchwp.com/documentation/knowledge-base/search-woocommerce-orders/
add_action( 'searchwp\source\post\attributes\comments', function() {
if ( did_action( 'searchwp\indexer\batch' ) ) {
remove_filter( 'comments_clauses', [ 'WC_Comments', 'exclude_order_comments' ] );
}
} );
// Add Order Notes to SearchWP's Comments Source.
add_filter( 'searchwp\source\comment\db_where', function( $db_where, $source ) {
$db_where[0]['value'] = [ 'comment', 'order_note', ];
$db_where[0]['compare'] = 'IN';
return $db_where;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment