Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Search box width not looks good › Reply To: Search box width not looks good
December 7, 2021 at 1:47 pm
#35906
Keymaster
You can try this variation, but even the previous one worked just fine on our ends:
add_filter( 'asp_results', 'asp_get_main_prod_img', 10, 1 );
function asp_get_main_prod_img($results) {
foreach ( $results as $k => &$r ) {
if ( isset($r->post_type) && $r->post_type == 'product_variation' && empty($r->image) ) {
$wc_prod_var_o = wc_get_product( $r->id );
$img = wp_get_attachment_image_src(
get_post_thumbnail_id($wc_prod_var_o->get_parent_id())
);
if (isset($img, $img[0]) && !is_wp_error($img)) {
$r->image = $img[0];
}
}
}
return $results;
}