Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Tell SearchWP's indexer to index WooCommerce Order Numbers as extra metadata
<?php
/**
* Tell SearchWP's indexer to index WooCommerce Order Numbers as extra metadata
*
* @param $extra_meta
* @param $post_being_indexed
*
* @return mixed
*/
function my_searchwp_index_wc_order_number( $extra_meta, $post_being_indexed ) {
if ( 'shop_order' !== get_post_type( $post_being_indexed ) ) {
return $extra_meta;
}
// Index plain order number and these variants:
// order-{order_number}
// o-{order_number}
$extra_meta['searchwp_order_number'] = $post_being_indexed->ID . ' order-' . $post_being_indexed->ID . ' o-' . $post_being_indexed->ID;
return $extra_meta;
}
add_filter( 'searchwp_extra_metadata', 'my_searchwp_index_wc_order_number', 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.