This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Search box width not looks good

#35906
Ernest MarcinkoErnest Marcinko
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;
}