Hello, currently the search function will show result based on the product title/product category/etc.
In functions.php, I manually create a custom field. This is the codes :-
/** Add Sub-Title option in Woocommerce */
add_action( 'woocommerce_product_options_general_product_data', 'my_custom_field' );
function my_custom_field() {
woocommerce_wp_text_input(
array(
'id' => '_subtitle',
'label' => __( 'Reference', 'woocommerce' ),
'placeholder' => 'Reference code',
'description' => __( 'Enter the reference code', 'woocommerce' )
)
);
}
add_action( 'woocommerce_process_product_meta', 'my_custom_field_save' );
function my_custom_field_save( $post_id ){
$subtitle = $_POST['_subtitle'];
if( !empty( $subtitle ) )
update_post_meta( $post_id, '_subtitle', esc_attr( $subtitle ) );
}
Now, can I include this meta field value for the search result too? Where I should edit the code?