Last active
June 9, 2021 01:00
-
-
Save jchristopher/1d66f1f410a1b5376316d213b3f29065 to your computer and use it in GitHub Desktop.
Make WooCommerce Order Notes searchable by SearchWP
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
<?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