How to load woocommerce category id in theme search page by my theme (for example Mustang Lite is my theme ) $cat_id=1242; thets my code. how to detect a category id at som products
global $woocommerce;
global $wp_query;
$cat_id=1242;
$table_name = $wpdb->prefix . "woocommerce_termmeta";
$query="SELECT meta_value FROM {$table_name} WHERE `meta_key`='thumbnail_id' and woocommerce_term_id ={$cat_id} LIMIT 0 , 30";
$result = $wpdb->get_results($query);
foreach($result as $result1){
$img_id= $result1->meta_value;
}
echo '<img src="'.wp_get_attachment_url( $img_id ).'" alt="category image">';