I've customized a plugin as per my client's need. With the plugin he can search for a product and can see the searched product's price history. Now my client asked me to change the product search into category search. I've tried a lot but don't know how to achieve that?
here is code of product search used in the plugin file
private function show_product_history_form_handler(){
if( isset($_POST['wsh_product_id_to_search']) ){
$searched_ID = $_POST['wsh_product_id_to_search'];
}
?>
<form action="<?php echo $_SERVER['PHP_SELF'] . '?page=wsh-save-history-tab' ?>" method="post">
<h2><?php echo __('Get prices history of product', 'wsh'); ?></h2>
<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="woocommerce_price_thousand_sep">Product ID</label>
</th>
<td class="forminp forminp-text" id="wsh_autocomplete_selector">
<input type="hidden" class="js-example-basic-multiple" name="wsh_product_id_to_search">
</td>
</tr>
</tbody>
</table>
<input class="button-large button-primary" type="submit" value="Show history" />
</form>
<?php
if( !empty( $searched_ID ) ){
$_product = wc_get_product( $searched_ID );
if( $_product->is_type('variable') ){
$variations = $_product->get_available_variations();
foreach ($variations as $variation) {
$this->show_table_prices_history( $variation['variation_id'], $searched_ID );
}
} else {
$this->show_table_prices_history( trim( $searched_ID ) );
}
}
}
kindly, can anyone help me to solve this?
Thanks in advance
question from:
https://stackoverflow.com/questions/65949798/adding-product-category-search-in-woocommerce-plugin 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…