Orders::search_box( $text, $input_id )
Source
File: src/Tickets/Commerce/Admin_Tables/Orders.php
public function search_box( $text, $input_id ) {
// Workaround to show the search box even when no items are found.
$old_items = $this->items;
$this->items = [
'Temporary',
];
// Get normal search box HTML to override.
ob_start();
parent::search_box( $text, $input_id );
$search_box = ob_get_clean();
// Assign the custom search name.
$search_box = str_replace( 'name="s"', 'name="' . esc_attr( $this->search_box_input_name ) . '"', $search_box );
// And get its value upon reloading the page to display its search results so user knows what they searched for.
$search_box = str_replace( 'value=""', 'value="' . esc_attr( tribe_get_request_var( $this->search_box_input_name ) ) . '"', $search_box );
$this->items = $old_items;
// Default selection.
$selected = 'purchaser_full_name';
$search_type = sanitize_text_field( tribe_get_request_var( $this->search_type_slug ) );
$options = $this->get_search_options();
if (
$search_type
&& array_key_exists( $search_type, $options )
) {
$selected = $search_type;
}
$template_vars = [
'options' => $options,
'selected' => $selected,
];
$custom_search = tribe( \TEC\Tickets\Commerce\Reports\Orders::class )->get_template()->template( 'orders/search-options', $template_vars, false );
// Add our search type dropdown before the search box input
$search_box = str_replace( '<input type="submit"', $custom_search . '<input type="submit"', $search_box );
echo $search_box;
}