get_image_id(), 'woocommerce_thumbnail'); $swap = null; if ($product->is_type('variable')) { foreach ($product->get_available_variations() as $variation) { if (!empty($variation['image']['src'])) { $swap = $variation['image']['src']; break; } } } if (!$swap) { $gallery = $product->get_gallery_image_ids(); if (!empty($gallery)) $swap = wp_get_attachment_image_url($gallery[0], 'woocommerce_thumbnail'); } ?> <?php echo esc_attr($product->get_name()); ?>